Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

help with sprintf

by mhearse (Chaplain)
on Jun 20, 2012 at 16:33 UTC ( #977397=perlquestion: print w/replies, xml ) Need Help??
mhearse has asked for the wisdom of the Perl Monks concerning the following question:

I'm needing help with sprintf. Specifically I need something that generates this list of 4 digit 24 hours. Thanks.
0000 0100 0200 0300 0400 0500 0600 0700 0800 0900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2100 2200 2300

Replies are listed 'Best First'.
Re: help with sprintf
by toolic (Bishop) on Jun 20, 2012 at 16:38 UTC
Re: help with sprintf
by cheekuperl (Monk) on Jun 20, 2012 at 16:41 UTC
    @list=map {$_.="00"}("00".."23"); print join("\n",@list);
    Why specifically sprintf?
      The only reason is that I want those hours in an array:
      my @times; for (0..23) { push @times, sprintf "%02d00", $_; } print Dumper(\@times);

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2016-10-24 19:47 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (309 votes). Check out past polls.