in reply to English Date-Suffixes

You can get it down another 6 chars to 41 by a little rewriting, and the $ in the regex and final semi-colon aren't needed:
shift;/1\d/?0:qw(0 st nd rd)[$_%10]or'th'

.02

cLive ;-)

Replies are listed 'Best First'.
Re: Re: English Date-Suffixes
by BrowserUk (Patriarch) on Nov 04, 2002 at 19:52 UTC

    If you can live with the risk of the sub stomping on the callers copy of $_ by not localising it, then you could trim a couple more keystrokes by using pop instead of shift, and you also can trim the regex by another 1

    pop;/1./?0:qw(0 st nd rd)[$_%10]or'th'

    Nah! Your thinking of Simon Templar, originally played by Roger Moore and later by Ian Ogilvy
Re: Re: English Date-Suffixes
by petral (Curate) on Nov 05, 2002 at 00:45 UTC
    Is this what you want? (Neither pop nor shift load $_ by defalult -- they just default to using @_ in a sub or @ARGV in the main prog.)
    $_=pop;qw(0 st nd rd)[!/1./&&$_%10]or'th'


      p