in reply to How to generate a report based on keyword?

Here you go - (windows solution - change to single quote for linux):
perl -ne "$h{$c=$1}=0 if m/^([\w\s]+pool)$/;m/^\d{6}\s+\w{4}/ and $h{$ +c}++;END{print qq|$_\t$h{$_}\n| for sort keys %h}" FILENAME

     Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

Replies are listed 'Best First'.
Re^2: How to generate a report based on keyword?
by perl_newbie99 (Initiate) on May 17, 2010 at 21:12 UTC

    @NetWallah: Your solution worked perfectly fine and the way I wanted. Thanks a lot! Much appreciated.

    #!/bin/ksh perl -ne '$h{$c=$1}=0 if m/^([\w\s]+pool)$/;m/^\d{6}\s+\w{4}/ and $h{$ +c}++;END{print qq|$_\t$h{$_}\n| for sort keys %h}' REPORT1