my $str = "begin here Time: 1041; foo Time: 917; bar Time: fred; Time: 2313; end"; my @arr; while ( $str =~ /Time: (\d+); /g ) { push @arr, $1; }