in reply to Parsing timestamps

You could do two tests. First test for PASS, then check the time. I find two tests easier than a look ahead/behind scheme.

Phil

Replies are listed 'Best First'.
Re^2: Parsing timestamps
by Fletch (Bishop) on Nov 04, 2005 at 15:42 UTC

    Not to mention that just doing the quick qualifying check (next unless /\*PASS\*$/) will prevent you from doing the more intensive parsing work unless it's a line you're really interested in (granted parsing out the date's not that much work, but . . . :).

Re^2: Parsing timestamps
by ww (Archbishop) on Nov 04, 2005 at 15:51 UTC
      ...or the first might be (if *PASS*\s is always last before the newline, as your data suggests):
    while ( <DATA> ) { print "$_ \n"; if ( $_ =~ /(\*PASS\*)\s$/ ) { print "\n \$1 is: $1 \n"; } else { print "Not found\n"; } } __DATA__ 2005-11-04/08:02:14.011 METRIC 00020036-0800093A log :Monitor: CALLER +Status *PASS* 2005-11-04/08:09:34.712 METRIC 0A475-11B Log :monitor: CALLER Status +*FAIL* 2005-11-04/08:11:30.924 METRIC 00020036-08000940 log :Monitor: CALLER +Status *PASS* 2005-11-04/08:12:29.830 METRIC 00020036-08000941 log :Monitor: CALLER +Status *PASS* 2005-11-04/09:12:28.790 METRIC 00020036-08000943 log :Monitor: CALLER +Status *PASS* 2005-11-04/09:12:35.869 METRIC 00020036-08000944 log :Monitor: CALLER +Status *PASS*

    output is:
    2005-11-04/08:02:14.011 METRIC 00020036-0800093A log :Monitor: CALLER +Status *PASS* $1 is: *PASS* 2005-11-04/08:09:34.712 METRIC 0A475-11B Log :monitor: CALLER Status +*FAIL* Not found 2005-11-04/08:11:30.924 METRIC 00020036-08000940 log :Monitor: CALLER +Status *PASS* $1 is: *PASS* 2005-11-04/08:12:29.830 METRIC 00020036-08000941 log :Monitor: CALLER +Status *PASS* $1 is: *PASS* 2005-11-04/09:12:28.790 METRIC 00020036-08000943 log :Monitor: CALLER +Status *PASS* $1 is: *PASS* 2005-11-04/09:12:35.869 METRIC 00020036-08000944 log :Monitor: CALLER +Status *PASS* $1 is: *PASS*