Solved

Perl

Posted on 2011-02-28
2
531 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

14 Experts available now in Live!

Get 1:1 Help Now