in reply to count digit in a numeric value



with length()..
$str=123; $fu = length($str); print $fu,"\n";

hm..
To count the digits in an alphanum string..
perl -e '$str="fff123"; $fu = ($str =~ tr/[a-z]//c); print $fu,"\n";'
I know, it's not what you asked, just trying to complicate things needlessly:)

updated, pls see following reply

Replies are listed 'Best First'.
Re^2: count digit in a numeric value
by wusphere (Novice) on Aug 15, 2004 at 04:16 UTC
    Thanks
Re^2: count digit in a numeric value
by hsinclai (Deacon) on Aug 16, 2004 at 03:11 UTC
    wusphere pay no attention to the one liner above, it's wrong, and off the point of your original question, as was pointed out offline .. brackets don't belong in tr///, should be looking for digits not anything else like a-z ..
    perl -e '$str="fff123"; $fu = $str =~ tr/0-9//c; print $fu,"\n";'

    Which is what Zaxo said anyway.