in reply to return code for finding a keyword within a line
The following code will exit (with an appropriate error code) on the first line it encounters that has a time in brackets that isn't 60. The error code will be the time it found.
my @test_data = ( qw/bananas apples oranges/, 'Thu Oct 18 21:26:36 2007: Time for all triggers in report period +(60s): 1.330981s', 'Thu Oct 18 21:27:36 2007: Time for all triggers in report period +(120s): 1.457271s', 'Thu Oct 18 21:28:36 2007: Time for all triggers in report period +(300s): 1.340150s' ); for ( @test_data ) { if ( m/\((\d+)s\)/ && $1 != 60 ) { print "$_\n"; exit $1 } }
|
|---|