Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Basic programming question

by ysth (Canon)
on Jan 27, 2005 at 07:09 UTC ( #425493=note: print w/replies, xml ) Need Help??


in reply to Basic programming question

Assuming $hour is 0..23 initially,
my $T; for my $hour (0..23) { print "in: $hour "; if ($hour > 11) { $T = 'PM'; } else { $T = 'AM'; } ($hour %= 12) ||= 12; print "out: $hour $T\n"; } __END__ in: 0 out: 12 AM in: 1 out: 1 AM in: 2 out: 2 AM in: 3 out: 3 AM in: 4 out: 4 AM in: 5 out: 5 AM in: 6 out: 6 AM in: 7 out: 7 AM in: 8 out: 8 AM in: 9 out: 9 AM in: 10 out: 10 AM in: 11 out: 11 AM in: 12 out: 12 PM in: 13 out: 1 PM in: 14 out: 2 PM in: 15 out: 3 PM in: 16 out: 4 PM in: 17 out: 5 PM in: 18 out: 6 PM in: 19 out: 7 PM in: 20 out: 8 PM in: 21 out: 9 PM in: 22 out: 10 PM in: 23 out: 11 PM

Replies are listed 'Best First'.
Re^2: Basic programming question
by merlyn (Sage) on Jan 27, 2005 at 13:01 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://425493]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2022-12-02 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?