Hi Morning,

I have a package file in "./test" dir.

$ ls test/
mytest.pm


I try to include it but got failed.

$ perl -le 'use mytest'
Can't locate mytest.pm 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/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at -e line 1.


It provide the info losing something in @INC.

Thus I do:

$ perl -le 'push @INC,"./test"; use mytest'
Can't locate mytest.pm 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/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at -e line 1.


Still got failed.

Someone pointed to me that I should push @INC in BEGIN{}.

$ perl -le 'BEGIN {push @INC,"./test"} use mytest'

This works.

So my question is what happens in BEGIN{} block?

thanks.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to