in reply to CGI table rows from an array

I think map is what you're looking for instead of the foreach in there:
my @rows = ( [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11, 12 ], ); print table({-border=>1},Tr([ th(['Document', 'X', 'Y', 'Z']), map { td([ map { a({-href=>$_},$_) } @$_ ]) } @rows ]) );

Replies are listed 'Best First'.
Re^2: CGI table rows from an array
by Melly (Chaplain) on Oct 10, 2006 at 13:48 UTC

    Indeed it is - many thanks. Never used map before.

    ...and the final code:

    print table({-border=>1}, Tr([ th(['Document', 'On TWiki']), map{ td([ a({-href=>$$_[2]},$$_[3]), a({-href=>$$_[1]},$$_[0]) ]) } @filesout ]) );
    Tom Melly, tom@tomandlu.co.uk