Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Re: foreach problem

by sacked (Hermit)
on May 18, 2004 at 17:05 UTC ( [id://354352]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: foreach problem
in thread foreach problem

Instead of map, you can use an inner for loop. Here, the inner loop adds four td's to an array (@table_cells). It then wraps @table_cells in a table row with Tr:
use File::Basename; # ... while( my @cols= splice @files, 0, 4 ) { my @table_cells; + for( 0..3 ) { push @table_cells => $cols[$_] ? td( submit(-name=>'file', -value=> basename($cols[$_])) ) : td( ' ' ); } + print Tr( {-align=>'center'}, @table_cells ); }
Or, again, use the distributive property of CGI's HTML functions:
while( my @cols= splice @files, 0, 4 ) { my @table_cells; + for( 0..3 ) { push @table_cells => $cols[$_] ? submit(-name=>'file', -value=> basename($cols[$_])) : ' '; } + print Tr( {-align=>'center'}, td(\@table_cells) ); }

--sacked

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://354352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-20 05:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found