in reply to Re^2: To find the no of occurenaces and max min value
in thread To find the no of occurenaces and max min value
Hay Madhavanll,
You should not use $2 has key in %hash, please find the modified code.
Please use code tag to post you code.use strict; use warnings; use Data::Dumper; my $file = './data.txt'; my %hash; open my $fh, '<', $file or die "Could not open '$file' $!"; while(<$fh>) { chomp(); if(/SQL :: (.*), Time Taken :: (.*)/i) { #print "$1=$3\n"; $hash{$1}->{count}++; $hash{$1}->{total} +=$2; if(defined $hash{$1}->{min}) { if ($hash{$1}->{min} > $2) { $hash{$1}->{min} = $2; } } else { $hash{$1}->{min} = $2; } if(defined $hash{$1}->{max}) { if ($hash{$1}->{max} < $2) { $hash{$1}->{max} = $2; } } else { $hash{$1}->{max} = $2; } } else { print "not matching\n"; } } print Dumper \%hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: To find the no of occurenaces and max min value
by Madhavan11 (Initiate) on Jul 14, 2014 at 13:58 UTC | |
by Random_Walk (Prior) on Jul 15, 2014 at 10:08 UTC |