in reply to split hash into two columns
my @keys = reverse sort {$hash{$a} <=> $hash{$b} || $a cmp $b} (keys % +hash); foreach my $i ( 0 .. int($#keys/2) ){ # printf "%s %s\n", @keys[$i, $i+int($#keys/2)+1]; # UPDATE: expanded to avoid 'uninitialized value' warning print $keys[$i]; my $j = $i+int($#keys/2)+1; print "\t" . $keys[$j] if $j <= $#keys; print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: split hash into two columns
by ikegami (Patriarch) on Mar 27, 2006 at 20:23 UTC | |
by Anonymous Monk on Mar 27, 2006 at 20:30 UTC | |
by ikegami (Patriarch) on Mar 27, 2006 at 20:41 UTC |