Here is the code of another small part of the full generator which will be in a seperate file of which there will be over a dozen. The first 3 scalars have default information in them. I would like to be able to change those values in the array (if necessary). I thought I had it right, but I don't get the expected result when I run on my computer.
#!/usr/bin/perl $b = beholder; $bk = "Monstrous Manual"; #default book $pg = 0; #defalt page number @gen = ( "beholder $b='' $pg=21", "death kiss $pg=21", "eye of the deep $pg=21", "gauth $pg=21", "spectator $pg=21", "undead $pg=21", "hive mother $pg=25", "director $pg=25", "examiner $pg=25", "lensman $pg=25", "overseer $pg=25", "watcher $pg=25" ); print "$gen[rand@gen] $b (<i>$bk</i>, pg $pg)", "\n";
The result I get is...
lensman 0=25 beholder (<i>Monstrous Manual</i>, pg 0)
instead of...
lensman beholder (<i>Monstrous Manual</i>, pg 25)
I tried moving the end quote to before the variables, but that just got me a lot of errors instead.
List of errors (condensed):
Scalar found where operator expected at C:\***\beholder.pl line 7, near ""beholder" $b" (Missing operator before $b?) line 7, near "'' $pg" (Missing operator before $pg?) line 8, near ""death kiss" $pg" (Missing operator before $pg?) line 9, near ""eye of the deep" $pg" (Missing operator before $pg?) line 10, near ""gauth" $pg" (Missing operator before $pg?) line 11, near ""spectator" $pg" (Missing operator before $pg?) line 12, near ""undead" $pg" (Missing operator before $pg?) line 13, near ""hive mother" $pg" (Missing operator before $pg?) line 14, near ""director" $pg" (Missing operator before $pg?) line 15, near ""examiner" $pg" (Missing operator before $pg?) line 16, near ""lensman" $pg" (Missing operator before $pg?) line 17, near ""overseer" $pg" (Missing operator before $pg?) line 18, near ""watcher" $pg" (Missing operator before $pg?) syntax error at C:\***\beholder.pl line 7, near ""beholder" $b" Execution of C:\***\beholder.pl aborted due to compilation errors.

In reply to Re: Creating a random generator by Lady_Aleena
in thread 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.