$str = 'abc dddd 10 '; ($number) = $str =~ /(\d+)\s*$/; print "$number";