my @matches = ($line =~ /$regexp/); #### my $regexp = "\d+: (\d+):(\d+):(\d+),\d+,\d+,(\d+)\.+$"; my ($hr,$min,$sec,$match) = ($field =~ /$regexp/); if ($match == '987') { ... #do whatever you have to do with $hr,$min,$sec