Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 about the Monastery: (6)
As of 2016-10-01 13:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (576 votes). Check out past polls.