in reply to Parsing Variables

Something like this:

#!/usr/bin/perl -w use strict; my $input='unixhelp pts/5 10.3.4.54 Fri Jun 13 11:08 still logged in unixhelp pts/5 10.3.4.00 Fri Jun 13 11:05 - 11:05 (00:00) unixhelp pts/5 10.3.4.00 Fri Jun 13 11:04 - 11:05 (00:00) unixhelp pts/5 10.3.4.00 Fri Jun 13 11:00 - 11:01 (00:00) unixhelp pts/5 10.3.4.00 Fri Jun 13 10:49 - 10:52 (00:03) unixhelp pts/8 10.3.4.00 Fri Jun 13 10:46 - 10:46 (00:00) unixhelp pts/3 10.3.4.00 Fri Jun 13 10:12 - 10:12 (00:00) unixhelp pts/3 10.3.4.00 Fri Jun 13 10:10 - 10:10 (00:00) unixhelp pts/3 10.3.4.00 Fri Jun 13 10:09 - 10:09 (00:00) unixhelp pts/3 10.3.4.00 Fri Jun 13 10:07 - 10:08 (00:00)'; @inputlines = split('\n', $input); print "Content-type: text/html\n\n"; print "<HTML><BODY>\n"; print " <TABLE>\n"; print " <TR>\n"; foreach (@inputlines) { print "<TD> $_ \n</TD>"; } print " </TR>\n"; print " </TABLE>\n"; print "<BODY><HTML>\n";

untested of course...

~~
naChoZ

Replies are listed 'Best First'.
Re: Re: Parsing Variables
by nimdokk (Vicar) on Jun 13, 2003 at 18:41 UTC
    You could also condense the separate print lines by using FORMAT commands (although it is a bit long and somewhat involved) or you could do:

    print qq/ Content-type: text/html <html><head></head> <body> <table> <tr>/; foreach (<@inputlines>) { print "<td>$_\n</td>"; } print qq/ </tr> </table> </body></html>/;
    Of course there is always more than one way to do it :-)

    "Ex libris un peut de tout"