NYIMI Jose (BMB) wrote: > perldoc -f length > > #!/usr/bin/perl -w > use strict; > > my $num=123; > my $match=length($num); > print "$match\n"; # should print 3 > > __END__ > > José. > > >> -----Original Message----- >> From: David Gilden [mailto:[EMAIL PROTECTED] >> Sent: Wednesday, March 12, 2003 5:09 PM >> To: [EMAIL PROTECTED] >> Subject: getting the number of characters >> >> >> 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 If you want to pad with zeroes then I assume you mean as leading zeroes, then use sprintf/printf "%05d", $num will place as 00123 or -00123. You use the 0 as part of the command%05d to tell sprintf/printf to use leading zeros. If you only do %5d then it is space leading. Wags ;) >> >> #!/usr/bin/perl -w >> >> $num =123; >> >> ($match) = ($num =~ m/(\d)/); > >> >> >> print "$match \n"; # should print 3 >> >> __END__ >>
********************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. **************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]