Chris E. Rempola wrote:
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?
It doesn't match an email address, it just matches any non-whitespace string
at the end of the line.
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!
$ perl -le'
$_ = qq[31 Aug 2007 04:00:22 GMT #8810118 337545 <[EMAIL PROTECTED]>
bouncing\n];
print $1 if /#.*\s<(\S+)>/;
'
[EMAIL PROTECTED]
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/