Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: Process mail logs

by aaron_baugher (Curate)
on Aug 13, 2012 at 12:19 UTC ( #987103=note: print w/replies, xml ) Need Help??

in reply to Re^2: Process mail logs
in thread Process mail logs

Certainly. The given/when (or for/when) construct is cleaner, but there's no reason you can't fall back on a series of if/elsif/else. (Though I'd recommend looking at the dispatch table concept first.) In your sample data, the fields appear consistent up to the 'directional' field you're looking at, so you could:

while(<DATA>){ chomp; my( $month, $day, $time, $host, $ppid, $date, $time2, $something, $d +irection, $remainder ) = split ' ', $_, 10; if( $direction eq '<=' ){ # go left } elsif( $direction eq '=>' ){ # go right } elsif( $direction eq '==' ){ # do a third thing } elsif( $direction eq '**' ){ # do a fourth thing } else { # fall back on a default behavior } }

Aaron B.
Available for small or large Perl jobs; see my home node.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2018-06-19 01:13 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.