while () { chomp; next unless /^(.*)(\d+:\d+:\d+)(.*?)$/; # if you're here, there was a match # do what you want with $1, $2 and $3 ... }