Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl use strict; use warnings; use Term::ReadKey; my $r = "\r"; my @bh = ( ['grass','Swishy swashy','long','wavy'], ['river','Splash splosh','deep','cold','A'], ['mud','Squelch squerch','thick','oozy'], ['forest','Stumble trip','big','dark','A'], ['snowstorm','Hoooo woooo','swirling','whirling','A'], ['cave','Tiptoe','narrow','gloomy','A'], ); my @br = ( 'One shiny wet nose', 'Two big furry ears', 'Two big goggly eyes', ); my @gh = ( ['Get to our front door','Open the door','Up the stairs'], ['Oh, no!','We forgot to shut the door','Back downstairs'], ['Shut the door','Back upstairs','Into the bedroom'], ['Into bed','Under the covers'], ); main(); exit(); sub nl { print $/; } sub pad { print " "; } sub e { print "@_!\n"; } sub p { print "@_.\n"; } sub going { p("We're going $_[0]"); } sub cantgo { p("We can't go $_[0] it"); } sub pause { nl(); print 'Press <SPACE> to continue.'; ReadMode('cbreak'); my $key = ReadKey(0); ReadMode('normal'); print $r," "x26,$r; } sub bearhunt{ my @w = @_; my ($s1,$s2); if (5 == @w) { $s1 = "$w[4] $w[0]"; $s2 = "$w[4] $w[2]"; } else { $s1 = ucfirst($w[0]); $s2 = ucfirst($w[2]); } $s2 .= ", $w[3] $w[0]"; going('on a bear hunt'); going('to catch a big one'); e('What a beautiful day'); p("We're not scared"); pause(); print'Oh-oh!'; pad(); e($s1); e($s2); cantgo('over'); cantgo('under'); pause(); e('Oh, no'); nl(); e("We've got to go through it"); pause(); for(1..3){ e($w[1]); } pause(); } sub backthrough{ my ($num, $what, $sound) = @_; $num = $num % 2 + 2; print 'Back through the ',$what,'! ',"$sound! "x$num; nl(); } sub run { my @l = @_; for my $l (@l) { p($l); } pause(); } sub title { nl(); print q("We're Going on a Bear Hunt"); nl(); pause(); } sub main{ title(); for my $bh (@bh) { bearhunt(@$bh); } print "WHAT'S THAT?"; nl(); pause(); for my $br (@br) { e($br); } pause(); e("IT'S A BEAR!!!"); pause(); print 'Quick!'; pad(); my @bt = reverse @bh; my $ct = 0; for my $bt (@bt) { $ct++; backthrough($ct, @$bt); } pause(); for my $gh (@gh) { run(@$gh); } p("We're not going on a bear hunt again"); nl(); }

In reply to We're Going on a Bear Hunt by Mr. Muskrat

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-24 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found