in reply to Perl Format the Output in table
#!/usr/bin/perl use warnings; use strict; open my $fh, "<", "output.txt" or die "could not open output.txt\n"; my %data; while(<$fh>){ chomp; $_=~ m/(.*?)\s++(\d++)/; my $site=$1; my $week=$2; $data{$site}{$week}++; } print "Domain/WeekNumber\tWeek28\tWeek29\tWeek30\tWeek31\n"; for my $site(sort keys %data){ print"$site\t\t"; for my $week (qw(28 29 30 31)){ unless(defined $data{$site}{$week} ){ print"NO\t"; }else{ print $data{$site}{$week} ."\t"; } } print"\n"; } close $fh;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl Format the Output in table
by Kenosis (Priest) on Oct 11, 2012 at 17:51 UTC | |
Re^2: Perl Format the Output in table
by ppnair (Initiate) on Oct 12, 2012 at 06:59 UTC |
In Section
Seekers of Perl Wisdom