in reply to array problem

@a = ABC isn't an array. Do you mean @a = ("A","B","C");? If so...

#!/agl/tools/perl/bin/perl my @a=qx (rsh -l sonaxisz 'source.login ; findbug -p | sort -u | %s se +rver); print "Content-type:text/html\n\n"; print "<html><body><table>"; for(@a){ print "<tr><td>$_</td></tr>"; } print "</table></body></html>";
the for loop takes each item in the list @a and applies the code within the loop - but you could use map instead:
@a = ("A","B","C"); print "Content-type:text/html\n\n"; print "<html><body><table>"; print map("<tr><td>$_</td></tr>",@a); print "</table></body></html>";
any good for you?

Replies are listed 'Best First'.
Re: Re: array problem
by bory (Beadle) on Sep 12, 2003 at 13:06 UTC
    It is a very good ideea but i am not sure if qx returns separate items for output! I relly don't think so! Do you know any quotelike operators that returns separate items for output! Thank you for your time!!

      Wait...qx will return a list of command output lines...if your pipeline outputs newline separated lines, then you'll get a list of the kind that you seem to want.

      Compare this code and its outputs with what you have done.

      my @a = map {s/\n//g ? $_ : ()} `netstat -an`; print "$_\n" for @a;