my $x = 'abc12345'; my ($y) = $x =~ /(\d+)$/; my $length = length($y); #### my $x = 'abc12345'; my $length = length ($x =~ /(\d+)$/); # returns 1, the length of the number in the number of elements #### my $x = 'abc12345'; my $length = map { length } ($x =~ /(\d+)$/); #### my $x = 'abc12345'; my $length = map { length } ($x =~ /(\d+)$/)[0]; #### my $x = 'abc12345'; my $length = length (($x =~ /(\d+)$/)[0]); # returns 5