On Feb 19, Daniel Falkenberg said:

>Just wondering if Perl is able to could how many digits there is in a
>variable.  Basically I want a user to be only able to enter 10 digits no
>more no less.  Is there a way perl can count this variable and with a
>little if/else statment I can display the result.

Well, Randal's answer is to make sure a variable consists ONLY of 10
digits -- if that's what you needed, ok.

If you want code that sees how many digits there are in a string, you can
use tr///:

  $digit_count = $str =~ tr/0-9//;

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to