Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: String Matching

by rpnoble419 (Pilgrim)
on Aug 14, 2012 at 07:08 UTC ( #987279=note: print w/replies, xml ) Need Help??

in reply to String Matching

If the layout is fixed (that is if the data changes but the position of the data does not change, then try this:
$_='May 2 04:06:15 exim[17905]: 2012-07-03 07:06:15 1SPP +tO-0004en-PS <= [] I=[6.5.1 +4.4]:25 P=esmtp S=13333 id=6aeca3b79b8892d6105dab131c76f066@localhost +.localdomain T="Half price offer"'; my @data= split(/ /); my $Email=$data[10]; my $IP=$data[12]; $IP=~s/\[//g; $IP=~s/\]//g; print "Email: $Email\n"; print "IP: $IP\n";
As you are limited to Perl 5.8.4, regex's are not as fast as in 5.10 and up so I would try to limit the data I perform a regex on as you never know what will change and cause your program to bomb (usually at 3:00am on a Sunday morning). I would split your data into its many parts and then run what ever regex you need on a smaller data chunk. For the email you don't even need a regex. The square brackets can be removed in any number of ways, I choose the lazy way in my example.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://987279]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2018-04-21 00:30 GMT
Find Nodes?
    Voting Booth?