The other answers so far have addressed your actual problem. I'd like to add a comment on your "validate.pm".

You start it with a shebang line, which is an odd thing to do since it is not actually executed (nor will any flags such as -w be parsed from the line by perl).

Usually (but only optionally) a module will declare its own name space and only export to the use'ing code subs that are requested:

in MyModule.pm:

package MyModule; use Exporter (); our @ISA = 'Exporter'; our @EXPORT_OK = qw/foo bar/; sub foo { "do some foo stuff" } sub bar { "do some bar stuff" } 1; # not actually needed since @EXPORT_OK= evaluates as true
and in the calling code:
use MyModule 'foo'; &foo();
You might take a look at perlmod.pod for more info on creating modules.

One last comment: one-level all-lowercase names like "validate" are usually for pragmas and are reserved for use by perl5-porters.


In reply to Re: Using a subroutine as a module by ysth
in thread Using a subroutine as a module by bradcathey

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.