Welcome to the Monastery | |
PerlMonks |
Re: Basic programming questionby sleepingsquirrel (Chaplain) |
on Jan 27, 2005 at 16:32 UTC ( [id://425608]=note: print w/replies, xml ) | Need Help?? |
Perl has a special conditional operator (the ternary ?:) which is custom made for just this type of thing.
update: Whoops, just noticed that the OP is also decreasing $hour for the "PM" case. In that case, the ternary operator becomes a little more ugly. Your best bet is probably one of the CPAN modules like dragonchild recommends. -- All code is 100% tested and functional unless otherwise noted.
In Section
Seekers of Perl Wisdom
|
|