I am deeply frustrated and it's not just because I'm stuck in this monastery with a bunch of bald blokes.

I'm never too good with scoping and I'm sure this is a dumb question but here goes. I've been using a hash for a long time within perl files in my webroot/cgi-bin directory that I initialise in the opening file with our %prod; Then in other files that are "use"d, I declare our %prod; and happily use it.

Now I've been gradually turning object oriented in my old age and for the first time, I want to use %prod in a package file called webroot/MG/Product.pm

Now when I do our %prod; and try to use it, I can't - it isn't populated. Presumably %prod is no longer in scope - perhaps due to the location of the file not being in the same directory? Anyway, please please can someone tell me how I can access %prod from my package. There seems to be very little on the function "our" in manuals and tutorials.

thanks.


In reply to our scope and packages by jfrm

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.