my @matches = '1 foo 22 bar 3' =~ /\d+/g; print "@matches"; #### 1 22 3 #### while (my $match = '1 foo 22 bar 3' =~ /(\d+)/g) { print "$1 "; } #### my @matches = '1 foo 22 bar 3' =~ /^\d+/g; print "@matches";