Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Perl module in a user local folder

by niqola (Novice)
on Jan 15, 2013 at 04:13 UTC ( #1013308=perlquestion: print w/replies, xml ) Need Help??
niqola has asked for the wisdom of the Perl Monks concerning the following question:

Hi! I'm writting perl module using OOP. All my modules ( and are in some_dir/Lib/ folder. My test script is in some_dir.
#file package UTest; use warnings; use strict; sub new { my $class = shift; my $self = { 'name' => '', 'condition' => '', 'args' => [], }; return bless $self, $class; } # other sub ... 1;
#file package Service; use UTest; our @ISA = qw(UTest); sub new { my ($class) = shift; my $self = UTest->new(); $self->{'captures'} = {}; bless $self, $class; return $self; } #others sub... 1;
#file use Lib::Service; my $service = Service->new; #... other codes
I get following error when i run
Can't locate in @INC (@INC contains: /etc/perl /usr/local/lib +/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/p +erl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl + .) at Lib/ line 2. BEGIN failed--compilation aborted at Lib/ line 2. Compilation failed in require at ./ line 2. BEGIN failed--compilation aborted at ./ line 2.
Can someone help me? Thanks.

Replies are listed 'Best First'.
Re: Perl module in a user local folder
by Athanasius (Chancellor) on Jan 15, 2013 at 04:32 UTC
      Thank you. That works fine!
Re: Perl module in a user local folder
by Anonymous Monk on Jan 15, 2013 at 04:40 UTC

    Or, you name your "service" module properly,
    by use, then in your test perl script, you can call use Lib::Service
    Infact, your Utest module should also be called
    Note that "::" is just like saying "Lib/" or "Lib/Service"
    Hope this helps.

      Thank you for your answer. But Perl compains about syntax error with use Maybe, i misunderstood something?
Re: Perl module in a user local folder
by sundialsvc4 (Abbot) on Jan 15, 2013 at 15:55 UTC

    Here or elsewhere, read up about this thing called @INC.   This is the list of places that Perl looks.   Other good search keys are PERL5LIB.   Entering perl -V on the command line (with an upper-case “V”) is also very informative.

    Also, very specifically, perldoc perlfaq8 where you will find a section specifically named, How do I add a directory to my include path (@INC) at runtime?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1013308]
Approved by Athanasius
Front-paged by 2teez
[Corion]: Meh. $effin_bad_system has an interface breakdown and then loads events in parallel with events overtaking one another instead of being processed sequentially
[shmem]: Discipulus: dunno, but we do all the time ^^
[choroba]: Discipulus I was taught so by a Londoner
[shmem]: Corion: very clear case of missing sequence number
[Corion]: shmem: Yeah. I guess they have a sequence number but distribute the events across threads or machines or whatever.
[karlgoethebier]: choroba: another chapter of "Learning English At The Monastry"?
[shmem]: Corion, well then... next issue, sequence number not a shared resource :P
[Discipulus]: shmem i'm searching it.. but failing i was sure was in Re: Let's Make PerlMonks Great Again! -- suggestions and dreams
erix recommends Vanished Kingdoms
[Corion]: shmem: Yeah, something like that. Not that that would be a solved issue. Simply process all events that come in from a single interface sequentially. Ah well.

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2017-05-23 08:25 GMT
Find Nodes?
    Voting Booth?