It looks like you just want to shuffle a deck of cards. If this is the case, then take a look at the module List::Util and shuffle. Here is your code redone using shuffle to order the cards randomly:
#!/usr/bin/perl -w use List::Util qw(shuffle); use strict; use warnings; my @cards = (2..10,qw(J Q K A)); my @suits = qw(h d c s); my @deck = map {my $suit = $_; map {"$_$suit"} @cards} @suits; my @newdeck = shuffle(@deck); print "@newdeck\n";
In reply to Re: Perl Subroutine
by wind
in thread Perl Subroutine
by craziestfire73
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |