NAME
Game::Gin::Card - a card is an integer, and everything else is derived
VERSION
Version 0.01
SYNOPSIS
use Game::Gin::Card qw(rank_of suit_of deadwood_of name_of id_of);
rank_of(1); # 1, an ace
suit_of(1); # 'S'
deadwood_of(1); # 1
name_of(1); # 'AS'
id_of('AS'); # 1
deadwood_of(13); # 10, a king
name_of(52); # 'KC'
DESCRIPTION
Cards are integers 1 to 52, suit-major: 1 to 13 are spades ace to king, 14 to 26 hearts, 27 to 39 diamonds, 40 to 52 clubs. A hand is therefore a list of small integers and a deal is a permutation.
The ace is low and only low
A-2-3 is a run and Q-K-A is not. Ranks are 1 to 13 with no wraparound anywhere, so the invalid run cannot be formed by arithmetic. Game::Gin::Meld depends on this.
FUNCTIONS
Nothing is exported by default.
rank_of
The rank as 1 to 13, where 1 is an ace and 13 a king. Dies for an id that is not a card.
suit_of
One of S, H, D, C.
deadwood_of
What the card counts against you when it is not in a meld: an ace 1, a court card 10, everything else its own number.
name_of
Two characters, rank then suit: AS, TD, QH. Ten is T so that every card is the same width.
long_name_of
ace of spades, for a sentence.
id_of
The id for a name, or undef. Case insensitive. This one parses input, so it returns undef rather than dying.
CARDS
52, as a constant.
AUTHOR
LNATION, <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION.
This is free software, licensed under the Artistic License 2.0.