Sponsored Content
Homework and Emergencies Homework & Coursework Questions Need help with a Perl Script using Pop, Shift, & Push Post 302707347 by Corona688 on Friday 28th of September 2012 11:37:12 AM
Old 09-28-2012
You already know how a for-loop works, it seems; the top 5 would just be another loop, from 0 to 5.

As for shuffling the cards, how does one usually shuffle a deck? Split it in half, then combine them randomly. I might try popping each card from the deck individually and putting them in either array A or B. Then looping until array A and B are both empty, popping a card from either A or B each loop and pushing it back into the original array. You could randomly choose which array you pick from.
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shift and push question in perl

hi, another perl question, I don't understand the below while (<FILE>) { push @last5, $_; #add to the end shift @last5 if @last5 > 5 ; #take from the beginning } can someone please explain to me how does shift @last5 if @last5 > 5 is taking last 5 lines from... (5 Replies)
Discussion started by: hankooknara
5 Replies

2. Shell Programming and Scripting

search & replace password perl script

I wanted a perl script to be done for Password search & replace in two files. For Example: Example 1)--i am having a file such as cat /opt/customer/Ariba/UAT/ariba/app/buyer/Server/config/Parameters.table Example 2)--and i am having a other file in other location such as cat... (4 Replies)
Discussion started by: shellscript22
4 Replies

3. Shell Programming and Scripting

Perl - if conditions is meet, push the last field of $_ into an array

I am using a seed file shown below to separate cisco devices by ios/os type. I want to bunch all the devices based on ios/os version. Once I find a match, I only want to push the ip address into the appropriate array. Example of seedfile 8 host1 (C3500XL-C3H2S-M) 11.0(5)WC17 10.1.44.21 9... (1 Reply)
Discussion started by: popeye
1 Replies

4. Shell Programming and Scripting

Shift Question (Perl)

I am attempting to write a script that reads each line of a file into a separate array and does some work on it then puts it all back together and I think I need to use the 'shift()' command to read each line into its own array, but I need help nesting it into a while loop (while not eof) So... (10 Replies)
Discussion started by: ifeatu
10 Replies

5. Shell Programming and Scripting

PERL, push to hash of array problem

$key = "a"; $value = "hello"; %myhash = {} ; push @{ myHash{$key} }, $hello; print $myHash{$key}."\n"; this script prints "hello" but has following error message. Reference found where even-sized list expected at ./test line 5. can any one help me to fix this problem?? (3 Replies)
Discussion started by: bonosungho
3 Replies

6. Shell Programming and Scripting

push and pop directories and subdirectories

I need to use pushd and popd to navigate all of the subdirectories in my current directory. I know how to get into each subdirectory, add it to the stack, and pop back out, but i cant figure out how to get into subdirectories deeper than the first without adding a foreach and if statement for... (1 Reply)
Discussion started by: ollie88r
1 Replies

7. UNIX for Dummies Questions & Answers

Setup a push script from NIS

Hi guys, can we get a pushed script for every NIS client like a policy.? I need to set a symbolic links for for every client. Thanks ... (1 Reply)
Discussion started by: pianz
1 Replies

8. Shell Programming and Scripting

Help on a script to push files once a day

Hello! Please I need some help on writing a script to push files from one server to the other once a day, everyday. I know that I can use this script on a crontab to send the files , but I am not sure how to start writing it, the actual script. I could start by declaring some variables: ... (4 Replies)
Discussion started by: fretagi
4 Replies

9. Web Development

Pop up confirmation box / perl cgi

Hi, I need to add confirmation pop up msg box before deleting the record from database, I have added following snippets to my code but its not working for me, your help will be much appreciated : print header; print <<EOF; <script type="text/javascript"> function confirmOk() { return... (0 Replies)
Discussion started by: terrykhatri531
0 Replies

10. Shell Programming and Scripting

Script to Push Files

Hey Guys, Thanks for always being helpful, I have another issue that I need a little insight on how to fix. See the below script I have and the error I get. I don't understand why it does that, am I not using the continue correctly? #!/bin/bash -x # @(#) File: filepush.sh #... (5 Replies)
Discussion started by: gkelly1117
5 Replies
CRIBBAGE(6)							   Games Manual 						       CRIBBAGE(6)

NAME
cribbage - the card game cribbage SYNOPSIS
/usr/games/cribbage [ -req ] name ... DESCRIPTION
Cribbage plays the card game cribbage, with the program playing one hand and the user the other. The program will initially ask the user if the rules of the game are needed - if so, it will print out the appropriate section from According to Hoyle with more (I). Cribbage options include: -e When the player makes a mistake scoring his hand or crib, provide an explanation of the correct score. (This is especially useful for beginning players.) -q Print a shorter form of all messages - this is only recommended for users who have played the game without specifying this option. -r Instead of asking the player to cut the deck, the program will randomly cut the deck. Cribbage first asks the player whether he wishes to play a short game ("once around", to 61) or a long game ("twice around", to 121). A response of `s' will result in a short game, any other response will play a long game. At the start of the first game, the program asks the player to cut the deck to determine who gets the first crib. The user should respond with a number between 0 and 51, indicating how many cards down the deck is to be cut. The player who cuts the lower ranked card gets the first crib. If more than one game is played, the loser of the previous game gets the first crib in the current game. For each hand, the program first prints the player's hand, whose crib it is, and then asks the player to discard two cards into the crib. The cards are prompted for one per line, and are typed as explained below. After discarding, the program cuts the deck (if it is the player's crib) or asks the player to cut the deck (if it's its crib); in the lat- ter case, the appropriate response is a number from 0 to 39 indicating how far down the remaining 40 cards are to be cut. After cutting the deck, play starts with the non-dealer (the person who doesn't have the crib) leading the first card. Play continues, as per cribbage, until all cards are exhausted. The program keeps track of the scoring of all points and the total of the cards on the table. After play, the hands are scored. The program requests the player to score his hand (and the crib, if it is his) by printing out the appropriate cards (and the cut card enclosed in brackets). Play continues until one player reaches the game limit (61 or 121). A carriage return when a numeric input is expected is equivalent to typing the lowest legal value; when cutting the deck this is equivalent to choosing the top card. Cards are specified as rank followed by suit. The ranks may be specified as one of: `a', `2', `3', `4', `5', `6', `7', `8', `9', `t', `j', `q', and `k', or alternatively, one of: "ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", and "king". Suits may be specified as: `s', `h', `d', and `c', or alternatively as: "spades", "hearts", "diamonds", and "clubs". A card may be specified as: <rank> " " <suit>, or: <rank> " of " <suit>. If the single letter rank and suit designations are used, the space separat- ing the suit and rank may be left out. Also, if only one card of the desired rank is playable, typing the rank is sufficient. For exam- ple, if your hand was "2H, 4D, 5C, 6H, JC, KD" and it was desired to discard the king of diamonds, any of the following could be typed: "k", "king", "kd", "k d", "k of d", "king d", "king of d", "k diamonds", "k of diamonds", "king diamonds", or "king of diamonds". FILES
/usr/games/cribbage AUTHORS
Earl T. Cohen wrote the logic. Ken Arnold added the screen oriented interface. 4th Berkeley Distribution May 6, 1986 CRIBBAGE(6)
All times are GMT -4. The time now is 02:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy