Dear Masters,
Suppose I have a code (mycode.pl) which uses my self created package (MyPackage.pm), and this package is stored under subdirectory ./modules_src/MyPackage.pm. My question is how can I appropriately call MyPackage.pm from mycode.pl?

I tried this but doesn't seem to work:
#!/usr/bin/perl -w # mycode.pl use 'modules_src/MyPackage'; # how can do this correctly? my $start = new Sth::MyPackage; # etc...
The overall code directory structure look simply like this:
~/MyPerl | |_modules_src |_MyPackage.pm | |_mycode.pl
And inside MyPackage.pm looks like this
package Sth:MyPackage; use 5.005; use strict; use vars qw( @ISA $VERSION ); # etc2... 1;
I am aware and have tested that executing mycode.pl is perfectly fine when I moved MyPackage.pm outside modules_src/, and use MyPackage; in mycode.pl. But my intention is to group those packages in one subdirectory.

---
neversaint and everlastingly indebted.......

In reply to Howto Call Package from a Subdirectory by neversaint

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.