in reply to Long array -> multiple columns?
It helps to write a function that prints the array in a defined number of columns:
sub print_in_n_cols { my ($count, @items) = @_; while (@items){ for (1 .. $count){ print "\t", shift @items; last unless @items; } print "\n"; } }
Now you can call that, based on the number of dupes:
if (@dupes <= 10){ print_in_n_cols(1, @dupes); } elsif (@dupes <= 20){ print_in_n_cols(2, @dupes); } ...
Actually I don't why you want this behaviour, it feels more natural to me to always print in four columns - but of course that's your choice.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Long array -> multiple columns?
by ikegami (Patriarch) on Jan 30, 2008 at 06:53 UTC | |
by azredwing (Sexton) on Jan 30, 2008 at 06:56 UTC |