#$string8 = (m/def(\d{8})/)[0]; #alternate way with list slice #### my $c = ("foo" =~ /($a)*$b/)[0];