in reply to Counting number of characters in a string
length
$cnt = @{[$str =~ /(\.)/g]}; [download]
use strict; use warnings; my $str = 'abc'; my $cnt = @{[$str =~ /(\.)/g]}; print "$cnt\n"; __END__ 0 [download]
Remove the backslash, add the "s" modifier. And the parens aren't necessary.
my $cnt = @{[$str =~ /./sg]}; [download]
Cheaper alternative:
my $cnt =()= $str =~ /./sg; [download]
0 1 2 3 4 5 6 7
Results (657 votes), past polls