cat sport_by_month
Month : Jan
sport :Football
sport :Volleyball
Month: Feb
sport :BasketBall
sport: Cricket
sport: Fotball
Month: Mar
Month: APR
sport : Bowling
sport : Climbing
I need your help to have a script that count the number of sports per month and sorted by mont with more sport, so my output would be something like
#!/usr/bin/perl
use Data::Dumper;
my %Hash = () ;
my ($fh , $mon , $name );
open $fh ,"<file" or die "Can not open the file : $@";
while ( <$fh> ) {
($mon , $name ) = split ( ':',$_ ), chomp ( $name ) , $Hash{$name} = 0 , next if ( /Month/ );
$Hash{$name}++ if ( /sport/ ) ;
}
print Dumper \%Hash;