Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??


#!/usr/bin/perl $a=5; + # Here we make a new variable called "a" to use as a simple loop co +unter. + # Now, we'll create some arrays, and start them off with some fresh + elements. @group=("swarm","heap","load","gang","squad","bunch","cluster","family +","team"); # This is an array, called group. Arrays are designated wi +th in at-symbol (@) prefix. @adjective=("crack-smoking","supple","furious","sexy","hyperactive","i +nquisitive","hot","old","crazy"); @noun=("midgets","Cuban refugees","clowns","bitches","programmers","ba +bies","dogs","hep-cats","apes"); while($a>0) + # This is a simple while-loop construct. It uses the same syntax as + Java, or C, { + # with one exception...You need to enclose even singular expression +s in braces. $index=rand(9); + # This generates a random integer between 0 and 9, and stores it in + $index print( "\nMr. T says, \"Daaaaammmn!!! A @group[$index]"); + # First part of the line is printed here, in this statement. $index=rand(9); + # A new number is generated, and stored in $index. print( " of @adjective[$index]"); + # The n'th element ($index) of the array is printed here. $index=rand(9); + # A new random number is generated and stored in $index. print( " @noun[$index] just ate my balls!!\""); + # The end of the line is printed. $a--; + # Our loop counter is decremented here, and the loop iterates. } print("\n\n"); + # Toss in a few newlines to keep things pretty, and we're all done!

In reply to "Ate My Balls" Syntax Generator by Anonymous Monk

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 pondering the Monastery: (7)
As of 2024-04-16 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found