Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi everyone,
I have a problem with some code tweeking.
The problem I have is that the columns are all messed up.
This is output I have
02:17 02:40 02:46 02:59 Apples 0 0 0 0 Grapes 7 7 7 7 bricks 0 0 0 0 TUBELIGHS 282 271 265 257 TOTAL 334 320 312 303
This is the part of the code I am using:
printf "%${lenght_frt}s ", " "; foreach (sort keys %date) { printf "%-${lenght_date}s ", $_; } print "\n"; foreach (sort keys %obj) { printf "%-${lenght_frt}s ", $_; for( my $i = 0; $i <= $#date; $i++) { if(exists($count{$_}->{$date[$i]})) { print " " x ($lenght_date), $count{$_}->{$date[$i]}; } } print "\n"; } close (FH); print "\n"; printf "%-${lenght_frt}s ", " TOTAL "; print map { sprintf "%7d", $_ }@tasks; print "\n"; }
How can I correct the code so that my output is clean like:
02:17 02:40 02:46 02:59 Apples 0 0 0 0 Grapes 7 7 7 7 bricks 0 0 0 0 TUBELIGHS 282 271 265 257 TOTAL 334 320 312 303
GREATEFULLY
Code tags and formatting added by GrandFather
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: arrange columns
by madbombX (Hermit) on Jul 29, 2006 at 07:10 UTC | |
|
Re: arrange columns
by fmerges (Chaplain) on Jul 29, 2006 at 07:34 UTC | |
by rodion (Chaplain) on Jul 29, 2006 at 12:23 UTC | |
|
Re: arrange columns
by liverpole (Monsignor) on Jul 29, 2006 at 15:22 UTC | |
by ambrus (Abbot) on Jul 29, 2006 at 23:33 UTC | |
|
Re: arrange columns
by GrandFather (Saint) on Jul 29, 2006 at 05:00 UTC | |
|
Re: arrange columns
by Ieronim (Friar) on Jul 29, 2006 at 11:29 UTC | |
|
Re: arrange columns
by jdporter (Paladin) on Jul 31, 2006 at 14:45 UTC |