Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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 leaves swirl about...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2017-11-21 22:17 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (312 votes). Check out past polls.