Solved

Perl

Posted on 2011-02-28
2
533 Views
Last Modified: 2012-05-11
Thanks ozo:

I was able to shuffle the cards but I'm only able to print out the top 16 cards and not the top 5. here is what I have:

#!/usr/bin/perl

@startingdeck = ("A H","2 H","3 H","4 H","5 H","6 H","7 H","8 H",
                 "9 H","10 H","J H","Q H","K H",
                 "A D","2 D","3 D","4 D","5 D","6 D","7 D","8 D",
                 "9 D","10 D","J D","Q D","K D",
                 "A C","2 C","3 C","4 C","5 C","6 C","7 C","8 C",
                 "9 C","10 C","J C","Q C","K C",
                 "A S","2 S","3 S","4 S","5 S","6 S","7 S","8 S",
                 "9 S","10 S","J S","Q S","K S");
@random_card = shuffle(@startingdeck);

foreach $line (@random_card){
       push(@startingdeck, shift(@random_card));
       push(@startingdeck,  pop(@random_card));
}
print 'random top 5 cards: ' .  join(',  ', @random_card) . "\n";

any guidance would be appreciated
0
Comment
Question by:craziestfire73
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 34996321
@random_card = shuffle(@startingdeck);
print 'random top 5 cards: ' .  join(',  ', @random_card[0..4]) . "\n";
0
 

Author Closing Comment

by:craziestfire73
ID: 34996401
Thanks, it was right in front of me all this time.

I guess I need a break.

Thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL Web Database 5 115
HTTP Error 502.2 - Bad Gateway 3 214
Add additional column to .csv using Perl. 8 138
combine multiple lines 2 59
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now