#!/usr/bin/env perl use 5.010; use warnings; my @times = map { /^(?:top - (..:..:..))/ } ; say for @times; __DATA__ top - 00:35:18 up top - 01:23:45 other junk completely different format altogether not - 01:23:45 can't fool me! top - 02:35:46 top - 03:46:07