in reply to Re^2: Counting number of characters in a string
in thread Counting number of characters in a string
This does not work for me. I expect the length of the string 'abc' to be 3, but your code returns 0:
use strict; use warnings; my $str = 'abc'; my $cnt = @{[$str =~ /(\.)/g]}; print "$cnt\n"; __END__ 0
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Counting number of characters in a string
by ikegami (Patriarch) on Jan 23, 2009 at 22:34 UTC | |
Re^4: Counting number of characters in a string
by levonbarker (Initiate) on Dec 30, 2010 at 17:09 UTC |
In Section
Seekers of Perl Wisdom