Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I'm having some trouble with this program. We're supposed to create a program with subroutines for Blackjack. The requirements are: Deck (1-10) Random Numbers; Plaver vs. Dealer; Bank (Sufficient Funds); Draw on 16; Stick on 17; 21 Wins; Dealer wins all ties; Calculate Funds available; Play until you want to quit or "Go bust"; Contains one or more subroutines I've never played Blackjack before so I'm more than a little confused. Here's my code:

#!/usr/bin/perl srand; print "How much money are you playing?"; $total = <STDIN>; print "What is your bet? "; $bet = <STDIN>; print "Here's your first card: "; $draw1 = int &draw; print $draw1; print "\nDealer has "; $dDraw = int &draw; print "\n $dDraw"; print "Would you like another card? y/n"; $another = <STDIN>; if ($another == 'y') { do{ $count = 2; print "You're $count card is: \n"; $draw2 = int &draw; print $draw2; print "Dealer has "; $dDraw = int &draw; print "$dDraw "; $count ++; $total = $draw1 + $draw2; print "\nWould you like another card? y/n"; $another = <STDIN>; }while ($total>0 && $another == 'y'); } else {if ($another == 'n') { print "$draw1 $draw2 ";}} sub draw { $draw = int rand(10); }

First, I'm getting stuck in an infinite loop in the if/dowhile part. I also can't figure out a way to count the cards up for both dealer and player and to calculate funds available. Any help?

In reply to Simple Blackjack progam help by ria1328

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    usemodperl slips on a banana skin

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (9)
    As of 2018-06-24 18:59 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (126 votes). Check out past polls.