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

Unfortunately this has to run on a stock Solaris 10 machine and it only comes with Perl 5.8.4

Is there another way ?

Replies are listed 'Best First'.
Re^3: Process mail logs
by aaron_baugher (Curate) on Aug 13, 2012 at 12:19 UTC

    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.