Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: sprintf vs. substr (for zero-padded values)

by dada (Chaplain)
on Jul 16, 2002 at 11:38 UTC ( [id://182045]=note: print w/replies, xml ) Need Help??


in reply to sprintf vs. substr (for zero-padded values)

if you're looking for speed (and you know $number is always less than 10 digits), why not do it this way:
sub three { my $number = "213"; my $padded = substr("000000000".$number, -9); #print $padded,"\n"; }
cheers,
Aldo
__END__ $_=q,just perl,,s, , another ,,s,$, hacker,,print;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://182045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-29 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found