Hi,

I created two of the bunch of modules I wanted to create. I decided to keep them in a subdirectory and access using Module::Submodule format.

Somehow it is not working for me. I get the error message "Undefined subroutine &main::method1 called at program.pl line 12.

The way I organised this is

Main program: ~/perl/program.pl

use strict; use warnings; use lib '/home/my_uname/perl/lib'; use Module::Submodule1; method1 (args); method2 (args);
The Modules are in the directory "~/perl/lib/Module" directory and have the following

Submodule1.pm: (Submodule2.pm is similar)

package Submodule1; use strict; use warnings; use Exporter; our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); @ISA = qw(Exporter); @EXPORT = qw(method1 method2); sub method1 { ... } sub method2 { ... } 1; __END__

It works if I copy the Submodule1.pm and Submodule2.pm files to ~/perl/lib/ directory.

These are not OO Modules -they are just subroutines. I am doing this just to keep all the subroutines of a particular category in a module. And of course all these Submodules are for an application (Module).

Also, I do not have root privileges to keep these modules in the /usr/bin/perl/lib (??) directory

Any help is appreciated


In reply to Creating a module in a directory to accomplish :: by newest_newbie

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.