perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Grimm <edgr...@asgard.rsc.raytheon.com>
Subject Re: UPD: output table with variable data
Date Thu, 20 Feb 2003 00:41:51 GMT
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: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message