http://www.perlmonks.org?node_id=1093525


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

You could consider using a database solution
#!perl use strict; use DBI; my $dbh = dbh('database.sqlite'); # input my $sth = $dbh->prepare('INSERT INTO DATA VALUES (?,?)'); while (<DATA>){ chomp; if ( /(select \* from \w+).*::(.*)/i ){ $sth->execute($1,$2); print "Data : [$1] [$2]\n"; } else { print "Skip : $_\n"; } } $dbh->commit; # report print '-'x55,"\n"; printf "%-20s %5s %5s %5s %5s %5s\n",('SQL','Count','Total','Min','Max +','Avg'); my $ar = $dbh->selectall_arrayref( 'SELECT F1,COUNT(F2),SUM(F2),MIN(F2),MAX(F2),AVG(F2) FROM DATA GROUP BY F1 ORDER BY F1'); for (@$ar){ printf "%-20s %5d %5d %5d %5d %5.1f\n",@$_; } close OUT; $dbh->disconnect; # create db sub dbh { my $dbfile = shift; unlink($dbfile) if (-e $dbfile); my $dbh = DBI->connect('dbi:SQLite:dbname='.$dbfile, undef, undef, {RaiseError =>1, AutoCommit =>0}) or die $DBI::errstr; $dbh->do('CREATE TABLE DATA (F1,F2 integer)'); $dbh->commit; return $dbh; } __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
poj