in reply to To find the no of occurenaces and max min value
use strict; use warnings; use Data::Dumper; my %hash; while(<DATA>) { chomp(); if(/from (\w+) (.*) Time Taken :: (\d+)/) { print "$1=$3\n"; $hash{$1}->{count}++; $hash{$1}->{total} +=$3; if(defined $hash{$1}->{min}) { if ($hash{$1}->{min} > $3) { $hash{$1}->{min} = $3; } } else { $hash{$1}->{min} = $3; } if(defined $hash{$1}->{max}) { if ($hash{$1}->{max} < $3) { $hash{$1}->{max} = $3; } } else { $hash{$1}->{max} = $3; } } else { print "not matching\n"; } } print Dumper \%hash; __DATA__ SQL :: select * from person ...etc , Time Taken :: 30 SQL :: select * from emp ...etc , Time Taken :: 5 SQL :: select * from home ...etc , Time Taken :: 20 SQL :: select * from emp ...etc , Time Taken :: 30 SQL :: select * from person ...etc , Time Taken :: 10 SQL :: select * from home ...etc , Time Taken :: 20 SQL :: select * from person ...etc , Time Taken :: 50
Sorry for the lengthy code. the hash contains the details u wanted, you can format it as u want.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: To find the no of occurenaces and max min value
by Madhavan11 (Initiate) on Jul 14, 2014 at 09:18 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |