未命名  

use strict;
my @cards;
my $how_many = 10;
my @colors = qw/hearts spades diamonds clubs/;
my @nums = qw/A 2 3 4 5 6 7 8 9 10 J Q K/;
foreach my $suit (@colors)
{
foreach my $num (@nums) {
push(@cards, [$num, $suit]);
}
}
foreach (1 .. $how_many)
{
my $idx = int(rand(scalar(@cards)));
my $card = splice(@cards, $idx, 1);
print "The card is $card->[1]:$card->[0]\n";
}

 

 

 

本文出自 “灿烂的笑” 博客,请务必保留此出处http://perfect.blog.51cto.com/650470/1066287

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()