Playing cards: Difference between revisions
m
→{{header|Perl}}: future-proof for 5.36
(Playing cards in Yabasic) |
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: future-proof for 5.36) |
||
Line 4,732:
use strict;
use warnings;
@Playing_Card_Deck::suits = qw
Line 4,747 ⟶ 4,748:
{my $invocant = shift;
my $class = ref($invocant) || $invocant;
my @cards
foreach my $suit (@Playing_Card_Deck::suits)
{foreach my $pip (@Playing_Card_Deck::pips)
Line 4,756 ⟶ 4,757:
# Removes the top card of the given deck and returns it as a hash
# with the keys "suit" and "pip".
{return %{ shift( @{shift(
sub shuffle
Line 4,770 ⟶ 4,771:
sub print_cards
# Prints out a description of every card in the deck, in order.
{print "$_->{pip} of $_->{suit}\n" foreach @{shift(
Some examples of use:
<syntaxhighlight lang="perl">my $deck =
$deck->shuffle;
my %card = $deck->deal;
|