File: cards.pl

package info (click to toggle)
libmath-random-mt-auto-perl 6.23-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 576 kB
  • sloc: perl: 1,068; makefile: 3
file content (31 lines) | stat: -rwxr-xr-x 551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl

use strict;
use warnings;

$| = 1;

use Math::Random::MT::Auto qw(shuffle);

MAIN:
{
    my $deck = shuffle(0..51);
    my @cards = qw(A 1 2 3 4 5 6 7 8 9 10 J Q K);
    my @suits = qw(C D H S);

    print('My hand: ');
    for my $card (0 .. 4) {
        print($cards[$$deck[$card] % 13], '-', $suits[$$deck[$card] / 13], '  ');
    }
    print("\n\n");

    print('Your hand: ');
    for my $card (5 .. 9) {
        print($cards[$$deck[$card] % 13], '-', $suits[$$deck[$card] / 13], '  ');
    }
    print("\n");
}

exit(0);

# EOF