John W. Krahn wrote:

my ( $key, %data );
while ( <> ) {
    if ( /#.*\s(\S+)/ ) {
        $key = $1;
        }
    elsif ( /\sremote\s/ ) {
        $data{ $key }++;
        }
    }

for my $key ( keys %data ) {
    print "'$key' sent $data{$key} emails.\n";
    }

John - Thanks so much!  Exactly what I needed.  Thanks for the insight! =)

Can you explain the regex syntax of /#.*\s(\S+)/

How does that match the email address? The reason why I ask is because I have one occurrence with the ouput of:

++++ OUTPUT +++++++++
'bouncing' sent 402 emails.
++++ /OUTPUT ++++++++

This was due to the fact that the format consisted of:

++++ FORMAT +++++++++
31 Aug 2007 04:00:22 GMT  #8810118  337545  <[EMAIL PROTECTED]>  bouncing
++++ /FORMAT +++++++++

So the script grabbed "bouncing" instead of the email address. I want to understand it so I can have it grab the email address in those instances. Thanks again!

-Chris

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to