anek77713 has asked for the wisdom of the Perl Monks concerning the following question:

Hello PerlMonks!

I have a problem.

I wrote a Perl Module of my own, and I don't understand how to use it.

I tried to make it work by using use lib "dir";

But no luck... :(

The question is: Do I have to install it somehow before using it????

Replies are listed 'Best First'.
Re: perl modules
by Happy-the-monk (Canon) on Sep 03, 2013 at 08:42 UTC

    I tried to make it work by using use lib "dir";

    You will also have to use your own module:

    use Somemodule;

    Cheers, Sören

    Créateur des bugs mobiles - let loose once, run everywhere.
    (hooked on the Perl Programming language)

      The path to the library where the module is:

      /home/DEV/user/mrm/lib

      The script:

      #!/usr/bin/perl use Modern::Perl; use lib "/home/DEV/user/mrm/lib"; use MRM::Utils; print MRM::Utils::now() . "\n\n";
      --------------------------------------------------

      Can't locate MRM/Utils.pm in @INC (@INC contains: /home/DEV/user/mrm/lib...BEGIN failed--compilation aborted at line 6

      I'm desperate :(

      If I use: use lib "/mrm/lib"; I get errors again:(

        Perl will be expecting the file to be called /home/DEV/user/mrm/lib/MRM/Utils.pm (and on most non-Windows filesystems, this is case-sensitive).

        If you're sure a file of that name exists, check its permissions, and the permissions of its parent and ancestor directories.

        use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
Re: perl modules
by tobyink (Canon) on Sep 03, 2013 at 08:55 UTC

    use lib "somepath" tells Perl where to look for modules, but not which module to look for!

    Assuming that you have two packages called Some::Module and Another::Module and they're saved as "mylibs/Some/Module.pm" and "mylibs/Another/Module.pm" respectively, then you could load them like this:

    use lib "mylibs"; use Some::Module; use Another::Module;
    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
Re: perl modules (@INC use lib absolutepath cwd)
by Anonymous Monk on Sep 03, 2013 at 08:38 UTC
Re: perl modules
by anek77713 (Acolyte) on Sep 03, 2013 at 11:09 UTC

    It's working!!

    Don't know why O_o strange.

    But now I have another error

    Can't open /var/logs/log_file_name.log (No such file or directory) at /usr/local/share/perl/5.14.2/Log/Log4perl/Appender/File.pm line 103.