Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: (Ovid) Re: front-pad a number with zero's

by japhy (Canon)
on Oct 30, 2001 at 23:32 UTC ( [id://122172]=note: print w/replies, xml ) Need Help??


in reply to (Ovid) Re: front-pad a number with zero's
in thread front-pad a number with zero's

A regex is overkill here. (If I'm saying it, trust me...) If you're against using sprintf(), just do the math:
sub pad { my ($num, $len) = @_; return '0' x ($len - length $num) . $num; }

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-04-25 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found