develooper Front page | perl.perl5.porters | Postings from March 2000

Re: [ID 20000307.005] Date Problem

From:
Russ Allbery
Date:
March 7, 2000 09:54
Subject:
Re: [ID 20000307.005] Date Problem
Message ID:
ylem9m3bun.fsf@windlord.stanford.edu
Jeff Pinyan <jeffp@crusoe.net> writes:

> Oh, and if you want the string "th" to follow the $day variable, then
> you can do something like

>   print "... the ${day}th of $month";

Or, more accurately:

# The endings for ordinal numbers.
@ORDINALS = ('th', 'st', 'nd', 'rd', ('th') x 17, 'st', 'nd', 'rd',
             ('th') x 7, 'st');

print "... the $day$ORDINALS[$day] of $month";

But this is getting off-topic.  :)

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About