in reply to
English Date-Suffixes
And
qw(0 st nd rd)[pop=~/(1?.)$/]or"th"
will do any integer.
Note that for pre-5.6 perl you have to do
(qw(...))[index]
because qw was translated into
split' ','...'
during compilation.
 
p
Comment on
Re: English Date-Suffixes
Select
or
Download
Code
Replies are listed 'Best First'.
Re: Re: English Date-Suffixes
by
locked_user mtve
(Deacon)
on Nov 10, 2002 at 09:36 UTC
small improvement:
(0,st,nd,rd)[pop=~/1?./g]||th
Re: Re: Re: English Date-Suffixes
by
petral
(Curate)
on Nov 12, 2002 at 20:07 UTC
Wow, didn't know about dropping the qw!
Why does the
||th
  lead to only returning the last value from the
/1?./g
-indexed list?
Update:
  I see, it becomes a comma list which returns the last value ("the result of the last expression").
see,
A list returns its last, an array returns its weight
 
p
[reply]
[d/l]
[select]
In Section
Meditations