Please bear with the as I am a complete novice in programming languages. The only languages that I know are HTML and CSS.

I would like to create a random generator for my website based on several charts, so that the users of my site will not have to manually roll for the results (manually meaning getting out a their dice).

Could someone please help me by showing me a basic generator, such as maybe how to randomly select a color (red, yellow, green, cyan, blue, magenta, white, gray, black)? From there, hopefully, it may be easier for me to understand how this language works.

Any help would be appreciated.

LA


Update

From the tutorials and replies below; here is a sample of some arrays that I have created for randomization.

print "content-type: text/html \n\n"; @AbilityName = qw(strength dexterity constitution intelligence wisdom +charisma ); @Class = qw(Warrior Rogue Priest Wizard Psionisist); @WeapType = qw(bludgeoning piercing slashing missile); @WeapMat = qw(bone metal stone wooden); @NWPlearn = ( "$AbilityName[rand @AbilityName] based", "$Class[rand @Class] specific" ); @Mutation = ( "unable to learn $NWPlearn[rand @NWPlearn] non-weapon proficiencies", "unable to learn $WeapType[rand @WeapType] weapons", "can not use $WeapMat[rand @WeapMat] weapons" ); print "Character mutation: $Mutation[rand @Mutation]", "\n";

This is only the beginning, some parts of the random generator that I would like to create are extremely complex, and these are just a small part of it. I just hope that I got it right so far.

Update 2

Learned a very valuable lesson, the order in which the arrays was listed is important. Also, qw only works on single word items, it doesn't seem to work on phrases. I may be wrong on that, but I will keep researching it. Updated the code above. So far, it works!


In reply to Creating a random generator by Lady_Aleena

Title:
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, details, 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, summary, 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.