CountryCode(3pm)

πŸ“¦
version 3.72 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

NCC::CountryCode β€” bestie, it's a Perl extension for blah blah blah. (the original page literally says that, and honestly? iconic. no notes.) It's your little group chat for country codes and country names. πŸŽ€


✨ SYNOPSIS ✨

  use NCC::CountryCode;

  my $cc = new NCC::CountryCode();

  my $cc_hash = $cc->getCCs();

  print ($cc->isCC('NL')) ? "exists" : "non-existing";

  $cc->CC2Country('fr');

  $cc->Country2CC('russia');

Like, that's the whole vibe. Make an object, ask it stuff, it tells you stuff. πŸ¦‹


🌸 DESCRIPTION 🌸

okay so this module is giving class + several methods, and the whole point of it is to make mapping between country names and country codes simple, the way they're assigned in ISO3166. Periodt. πŸ‘‘

The CC2Country() method maps a country code to the corresponding country name β€” or, if that code doesn't exist, an empty string. That's it. No drama, just a lookup. πŸ’…

The Country2CC() method tries to map the country name you pass in into a country code. But bestie, here's the thing β€” the spelling of the name may vary, so this function doesn't just do one lookup, it tries to find all possible matches for the name you passed. And the return type depends on the context, which is very main character of it:

  • In array context, the method returns a hash of country codes and names.
  • In scalar context, it returns a string containing all the possible country codes and their corresponding country names.

The isCC() method verifies that the country code you passed is actually a legal one, and if it is, it hands it back to you in UPPER CASE. Otherwise? Empty string. Bye. πŸ™ˆ

The getCCs() method returns a reference to the internal hash that contains all the country codes with their corresponding country names. All of them. The whole roster. πŸ’–


πŸ’€ BUGS πŸ’€

okay so this is the part where we keep it real. πŸ‘€

On top of the country codes defined by the ISO3166 standard, this module also introduces:

  • 'UK' as a synonim for 'GB'
  • 'EU' as an additional 'virtual' name for Europe itself

So yeah. It's not just ISO3166. Noted. not me being surprised by the extras tho 😭


🫢 AUTHOR 🫢

Timur Bakeyev, timur@ripe.net

shoutout to the author, fr fr πŸ’œ


🌈 SEE ALSO 🌈


and that's the page, bestie!! πŸŽ€ this one shipped with perl v5.32.0, dated 2021-01-26, from the User Contributed Perl Documentation collection, and it lives in the manual as CountryCode(3pm). go forth and map some countries. slay. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from