use strict; use warnings; my $str = 'wibble 10'; print "Matched $1\n" if $str =~ /(\d+)/g; print "Matched $1\n" if $str =~ /(\w+)/g; #### Matched 10