in reply to Re: printing unequal sized lists side by side
in thread printing unequal sized lists side by side
Consider your output, if @array1 and @array2 are swapped, making @array2 the longer of the two.
But one can make that output slightly more elegant (a matter of taste, of course; YMMV) by using the ternary again in print statements which make visual allowance for non-existent indices:
for(my $index=0; $index<$max_array_length; $index++) { print $array1[$index] ? $array1[$index] : ' '; print ", "; print $array2[$index] ? $array2[$index] : '-'; print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: printing unequal sized lists side by side
by nad04299 (Initiate) on May 28, 2011 at 13:00 UTC | |
|
Re^3: printing unequal sized lists side by side
by wind (Priest) on May 28, 2011 at 17:13 UTC |