Hi guys, I've loaded a file, and have removed the \n using chomp. however, when I try using length($file), it counts the whitespaces along with the characters. How do I just count the characters, anything but the whitespaces?
thanks
Printable View
Hi guys, I've loaded a file, and have removed the \n using chomp. however, when I try using length($file), it counts the whitespaces along with the characters. How do I just count the characters, anything but the whitespaces?
thanks
$str = "place the string you want to count in here";
$count = $str =~ s/([a-z])/$1/gi;
print $count;
$count = tr/a-zA-Z//;
perl -e "$_= 'blah blDh'; $count = tr/a-zA-Z//; print $count;"
perldoc perlop
or perl -e "$_= 'blah blDh'; print $count = tr/a-zA-Z//;"