in reply to Re^2: Incrementing string arrays when used with foreach loops
in thread Incrementing string arrays when used with foreach loops
That kinda backwards thinking for a deck of cards. The normal thought process involves shuffling the deck then drawing from the top.
use strict; use warnings; use List::Util qw( shuffle ); my @cards; for my $suit (qw(_clb _dmd _hrt _spd)) { for my $rank (2 .. 10, qw(j q k a)) { push @cards, $rank . $suit; } } my @deck = shuffle @cards; for (1 .. 10) { print(shift(@deck), "\n"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Incrementing string arrays when used with foreach loops
by toolic (Bishop) on Sep 11, 2008 at 03:05 UTC | |
|
Re^4: Incrementing string arrays when used with foreach loops
by hangon (Deacon) on Sep 12, 2008 at 09:25 UTC | |
by ikegami (Patriarch) on Sep 12, 2008 at 09:33 UTC | |
by tilly (Archbishop) on Sep 16, 2008 at 06:30 UTC |