Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

padding/substr quirk

by RolandGunslinger (Curate)
on Jan 10, 2004 at 21:30 UTC ( #320383=perlquestion: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!perl
    use strict;use warnings;
    ...
    print "substr day= " . (substr("0" . localtime->mday(), -2)) . "\n";
    print "sprintf month= " . (sprintf "%02d", localtime->mon() + 1) . "\n
    +";
    print "sprintf day= " . (sprintf "%02d", localtime->mday()) . "\n";
    
  2. or download this
    >perl pad.pl
    substr month= 1
    substr day= 09
    sprintf month= 01
    sprintf day= 09
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://320383]
Approved by Roger
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2014-08-21 16:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (136 votes), past polls