If you're going to call the sub in a [+ +] block, you should have the result returned, not printed. Note that, as others have mentioned, this is not the standard embperl way of doing things, but it's an option.
> sub interface_list (@interfacelist) > { my $res = " > <tr class=heading> > <td>Mon</td> > <td>Device</td> > <td>Interface</td> > <td>Speed</td> > <td>Line</td> > </tr> > "); > for $indx ( 0 .. $#interfacelist ) > { $res .= " > <tr class=light> > <td class= $interfacelist[$indx][0] ><a> $interfacelist[$indx][1] > </a></td> > <td><a href='view-device.epl?id_device=$interfacelist[$indx][2] '> > $interfacelist[$indx][3] </a></td> > <td><a href='view-interface.epl?id_interface= $interfacelist[$indx][4] '> > $interfacelist[$indx][5] </a></td> > <td><a href='view-line.epl?id_line= $interfacelist[$indx][6] '> > $interfacelist[$indx][7] </a></td> > </tr> > "); > }; return res; > } Ed On Wed, 19 Feb 2003, Alexander Hartmaier wrote: > > > Hi again! > > I made a mistake at the variable passing ;-) > Now this works: > > sub interface_list (@) > { > my @interfacelist = $_[0]; > . > . > . > } > > But it's still outputted at the end of the page instead of where I call the sub. > I also don't like the print statements. > > Any Idea? > > THX Alex > > ##################### > > Hi list! > > I have to output a html table in some of my embperl pages which always looks the > same but the data is slightly different. > My approch was to write a small sub which takes the array with the data and > looks like this: > > >---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > sub interface_list (@interfacelist) > { > print (" > <tr class=heading> > <td>Mon</td> > <td>Device</td> > <td>Interface</td> > <td>Speed</td> > <td>Line</td> > </tr> > "); > for $indx ( 0 .. $#interfacelist ) > { > print (" > <tr class=light> > <td class= $interfacelist[$indx][0] ><a> $interfacelist[$indx][1] > </a></td> > <td><a href='view-device.epl?id_device=$interfacelist[$indx][2] '> > $interfacelist[$indx][3] </a></td> > <td><a href='view-interface.epl?id_interface= $interfacelist[$indx][4] '> > $interfacelist[$indx][5] </a></td> > <td><a href='view-line.epl?id_line= $interfacelist[$indx][6] '> > $interfacelist[$indx][7] </a></td> > </tr> > "); > }; > } > >---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > My problem is that when I call the sub with '[+ interface_list (@interfacegrp) > +]' the lines are appended to the end of the output instead of the line where I > call it! > Furthermore the array @interfacelist is empty... > > I think there is a better way to handle this problem! > Gerald or anybody else has an idea? > > THX Alex > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]