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]
Ceramics Glass Wood Metal Plastic Paper Banana leaves Something else
Results (448 votes), past polls