my @tops; open my $inputFileHandle, '<', $filename or die "could not open '$filename', because the OS said: $!"; while ( <$inputFileHandle> ) { if ( m/^top \- (\d{2}:\d{2}:\d{2})/ ) { push @tops, $1; } }