On Fri, 2007-08-31 at 18:05 -0700, Chris E. Rempola wrote:
> I'm trying to parse qmail-qread data, but don't know how to find the
> number of occurrences after a particular string. Here is the data:
>
> +++++++++++ Beginning of data +++++++++++++++++++++++++++++++++++++++++
> 28 Aug 2007 17:00:47 GMT #8807850 41428 <[EMAIL PROTECTED]>
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
>
> 28 Aug 2007 17:00:47 GMT #8807850 41428 <[EMAIL PROTECTED]>
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> done remote [EMAIL PROTECTED]
> ++++++++++++ End of Data ++++++++++++++++++++++++++++++++++++++
>
> How would I make it look for the (#) sign and count every occurence of
> the word(remote) below it? So the script would know that
> '[EMAIL PROTECTED]' sent 10 emails and that '[EMAIL PROTECTED]' sent
> 5 emails. Any help appreciated. Thank you.
caveat emptor, untested but gives you the idea
my $line;
my $count;
while( $line = <> ) {
if( $line =~ m/#\d/ ) { # hash and a digit
$count = 0;
while( $line = <> ) {
if( $line !~ m/remote/ ) last; # exit first while loop
$count++;
}
print "Count $count\n";
}
}
--
Ken Foskey
FOSS developer
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/