my $sentence = "I fear that i will be extinct after 1000 years"; if($sentence =~ /(\d*)/) { print "That said '$1' years.\n"; }