Lingua::EN::Numbers::Ordinate(3pm)

Lingua::EN::Numbers::Ordinate3pm

Usage

  use Lingua::EN::Numbers::Ordinate;
  print ordinate(4), "\n";
   # prints 4th
  print ordinate(-342), "\n";
   # prints -342nd
  # Example of actual use:
  ...
  for(my $i = 0; $i < @records; $i++) {
    unless(is_valid($record[$i]) {
      warn "The ", ordinate($i), " record is invalid!\n"; 
      next;
    }
    ...
  }

Overview

There are two kinds of numbers in English -- cardinals (1, 2, 3...), and ordinals (1st, 2nd, 3rd...). This library provides functions for giving the ordinal form of a number, given its cardinal value.

Functions

ordinate(SCALAR)

Returns a string consisting of that scalar's string form, plus the appropriate ordinal suffix. Example: ordinate(23) returns "23rd".

As a special case, ordinate(undef) and ordinate("") return "0th", not "th".

This function is exported by default.

th(SCALAR)

Merely an alias for "ordinate", but not exported by default.

ordsuf(SCALAR)

Returns just the appropriate ordinal suffix for the given scalar numeric value. This is what "ordinate" uses to actually do its work. For example, ordsuf(3) is "rd".

Not exported by default.

The above functions are all prototyped to take a scalar value, so ordinate(@stuff) is the same as "ordinate(scalar @stuff)".

Caveats

* Note that this library knows only about numbers, not number-words. ordinate('seven') might just as well be ordinate('superglue') or ordinate("\x1E\x9A") -- you'll get the fallthru case of the input string plus "th".

* As is unavoidable, ordinate(0256) returns "174th" (because ordinate sees the value 174). Similarly, ordinate(1E12) returns "1000000000000th". Returning "trillionth" would be nice, but that's an awfully atypical case.

* Note that this library's algorithm (as well as the basic concept and implementation of ordinal numbers) is totally language specific.

To pick a trivial example, consider that in French, 1 ordinates as "1ier", whereas 41 ordinates as "41ieme".

Repository

<https://github.com/neilb/Lingua-EN-Numbers-Ordinate>

Releases

12 releases since Debian 3.1 (Sarge); the text changed 6 times.

  1. 3.1
  2. 4.0–7
  3. 8
  4. 9–10
  5. 11
  6. 12–13
  7. Arch

Author

Sean M. Burke "[email protected]"

This has been maintained by Neil Bowers (NEILB) since 2014.

From perl-lingua-en-numbers-ordinate 1.05-2 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.