in reply to Can this script be Optimized?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can this script be Optimized?
by Anonymous Monk on May 01, 2014 at 06:11 UTC | |
by NetWallah (Canon) on May 01, 2014 at 06:32 UTC |