in reply to Re: To find the no of occurenaces and max min value
in thread To find the no of occurenaces and max min value

Thanks for ur reply.. I tried with above code.. but still im not able to get the min and max values correctly. only 2 hash variables Please find the code


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{$2}->{total} +=$2; if(defined $hash{$2}->{min}) { if ($hash{$2}->{min} > $2) { $hash{$2}->{min} = $2; } } else { $hash{$2}->{min} = $2; } if(defined $hash{$2}->{max}) { if ($hash{$2}->{max} < $2) { $hash{$2}->{max} = $2; } } else { $hash{$2}->{max} = $2; } } else { print "not matching\n"; } } print Dumper \%hash;
Output should be
------------
SQL No of occu Min Max select * from person 3 10 50 select * from emp 2 5 30