On 7/23/07, Adriano Ferreira <[EMAIL PROTECTED]> wrote:
On 7/23/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
snip
> use File::Basename;
> use lib dirname( $0 );

Pay attention to the fact that the solution by Shawn does not work
snip

Um, yes it does.  At least with 5.8.8.  I thought I remembered an
issue with it as well, but it worked when I tested it.  I think this
may be 5.6 issue.  However, the use of the variable does not work due
to the reasons you talked about (the variable has not been assigned to
due to the nature of BEGIN blocks).  I think there must have been a
change between 5.6 and 5.8 that treats the arguments to a module as
being inside BEGIN (i.e. dirname will execute before being passed to
the lib module's import function).

[EMAIL PROTECTED]:~$ find test
test
test/Fork
test/Fork/It.pm
test/t.pl
[EMAIL PROTECTED]:~$ cat test/t.pl
#!/usr/bin/perl

use warnings;
use strict;

use File::Basename;
use lib dirname( $0 );
use Fork::It;

Fork::It::All();
[EMAIL PROTECTED]:~$ cat test/Fork/It.pm
package Fork::It;

sub All { print "fork it all\n" }

1;
[EMAIL PROTECTED]:~$ perl -e 'print join(":", @INC), "\n"'
/home/cowens/apps/perl/share/perl/5.8.8:/home/cowens/apps/perl/share/perl:/home/cowens/apps/perl/lib/perl/5.8.8:/home/cowens/apps/perl/lib/perl:/etc/perl:/usr/local/lib/perl/5.8.8:/usr/local/share/perl/5.8.8:/usr/lib/perl5:/usr/share/perl5:/usr/lib/perl/5.8:/usr/share/perl/5.8:/usr/local/lib/site_perl:.
[EMAIL PROTECTED]:~$ perl test/t.pl
fork it all

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to