use strict; use warnings; use Test::More tests => 2; my $re_dn = qr{^(\w+) (\d+) (\d{2}:\d{2}:\d{2}) .*: eth(\d): link down}; my $re_up = qr{^(\w+) (\d+) (\d{2}:\d{2}:\d{2}) .*: eth(\d): link up, (\d+)Mbps, ([^,]+), lpa (\w+)}; my @log = ( 'May 19 13:58:01 foo: eth0: link down', 'May 19 13:58:11 foo: eth0: link up, 100Mbps, bar, lpa quux' ); for (@log) { my @matches; if (@matches = /$re_dn/) { my ( $mon, $day, $time, $interface ) = @matches; is $time, '13:58:01'; next; } if (@matches = /$re_up/) { my ( $mon, $day, $time, $interface, $rate, $duplex, $lpa ) = @matches; is $time, '13:58:11'; next; } }