.------[ David Gilden wrote (2003/03/12 at 10:08:52) ]------
|
| Hello,
|
| I am looking for the $num to treated as a string and get the number
| of characters, in this case I am look for 3 to be returned.
|
| Later I want to use this number to pad a string with zeros....
| Thanks!
| Dave
|
| #!/usr/bin/perl -w
|
| $num =123;
|
| ($match) = ($num =~ m/(\d)/);
|
|
| print "$match \n"; # should print 3
|
| __END__
|
`-------------------------------------------------
If you're wanting to find the last digit in a scalar, you'll want to
modify this to be:
($match) = $num =~ /(\d)$/;
or if there is always there characters you can also do this:
($match) = $num =~ /\d\d(\d)/;
---------------------------------
Frank Wiles <[EMAIL PROTECTED]>
http://frank.wiles.org
---------------------------------
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]