Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Seeking the

by Parham (Friar)
on Feb 07, 2002 at 00:37 UTC ( #143758=note: print w/replies, xml ) Need Help??


in reply to Seeking the

Just a bit off topic...

Correctly speaking, sprintf() and printf() are probably the better solution. But it seems that you're unfamiliar with those and more comfortable concatinating leading zeros. There is absolutely nothing wrong with the way your doing things, there is always more than one way to do things and your way seems just as good as any other.

to answer your question though:
$day = 5; #test variable $month = 7; #test variable $day = sprintf("%02d",$day); $month = sprintf("%02d",$month); print "$day\n$month";
would print:
05
07

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://143758]
help
Chatterbox?
[erix]: my favorit scientist Darwin-reply was a good sly move to keep the chattering going ;)
[erix]: I've drawn several continents into the quicksand if I'm not mistaken

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-12-15 12:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (432 votes). Check out past polls.

    Notices?