Produces the same output as your code.print join( ",\t" => my @kk=sort keys %$Hash ), $/; my $row = 0; my $items_in_row; do { $items_in_row = 0; my $v; for my $k (@kk){ if (defined ($v = $Hash->{$k}[$row])) { $items_in_row ++; }else{ $v=""; } print "$v\t" } print "$/"; $row++; } until $items_in_row == 0;
Update: Another version:
print join( ",\t" => my @kk=sort keys %$Hash ), $/; my $items_in_row; my $row=0; do { $items_in_row = 0; my $v; print +(map{ if ( defined ($v = $Hash->{$_}[$row]) ){ $items_in_row++ ; "$v\t" }else{ "\t" } } @kk ), "$/"; $row++; } until $items_in_row == 0;
What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
-Larry Wall, 1992
In reply to Re: Can this script be Optimized?
by NetWallah
in thread Can this script be Optimized?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |