The error doesn't completely go away if you use Data::Dumper; in your Util.pm. The second option, print Data::Dumper(%HASH) line still won't work, because that's just not how perl works.

Instead, if you want to import things, whether implicitly (such as Dumper from the Data::Dumper module) or explicitly (such as gzip from IO::Compress::Gzip), and then make them available to any module that uses your module, you need to explicitly mark those symbols for export, either by providing your own import routine, or using the one from Exporter or other module that provides export functionality.

However, I would only really recommend doing this for truly global functions - ones that really will be used essentially everywhere. I've done this, but I really mean the things I put in there were well and truly global - such as strict, warnings, feature, and a number of other modules that I expected 90%+ of the rest of my modules to require (translation services and trace-logging). Other required modules I would prefer making explicit when and where needed, not to keep the memory usage down, but to help self-documentation: making things explicit. The above ones I put into a "policy.pm" file because it was our policy to follow strict, enable all warnings, enable perl features explicitly and commonly across the project, to support translation, and to trace nearly everything.


In reply to Re: Perl includes to reuse code. by Tanktalus
in thread Perl includes to reuse code. 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":



  • 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.