in reply to printing unequal sized lists side by side
You can get it by following way
use strict; use warnings; my @array1=(1 .. 20); my @array2=('a' .. 'e' ); my $max_array_length=(scalar(@array1) > scalar(@array2)) ? scalar(@arr +ay1) : scalar(@array2); for(my $index=0; $index<$max_array_length; $index++) { print $array1[$index] if $array1[$index]; print ","; print $array2[$index] if $array2[$index]; print "\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: printing unequal sized lists side by side
by ww (Archbishop) on May 28, 2011 at 10:59 UTC | |
by nad04299 (Initiate) on May 28, 2011 at 13:00 UTC | |
by wind (Priest) on May 28, 2011 at 17:13 UTC |
In Section
Seekers of Perl Wisdom