From: Slaven Rezic Date: Thu, 1 May 2003 21:28:10 +0000 (+0200) Subject: perl 5.8.0, FindBin::again X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f509412828fa95d62b8d41774f816a14ba046cac;hp=9e3321a52c584b81da92f45d40c4d1a7450665a1;p=p5sagit%2Fp5-mst-13.2.git perl 5.8.0, FindBin::again Message-ID: <873cjy31rp.fsf@vran.herceg.de> p4raw-id: //depot/perl@21968 --- diff --git a/lib/FindBin.pm b/lib/FindBin.pm index 8be9cb6..4610beb 100644 --- a/lib/FindBin.pm +++ b/lib/FindBin.pm @@ -42,13 +42,19 @@ directory. =head1 KNOWN ISSUES If there are two modules using C from different directories -under the same interpreter, this won't work. Since C uses +under the same interpreter, this won't work. Since C uses a C block, it'll be executed only once, and only the first caller will get it right. This is a problem under mod_perl and other persistent Perl environments, where you shouldn't use this module. Which also means that you should avoid using C in modules that you plan to put -on CPAN. The only way to make sure that C will work is to force -the C block to be executed again: +on CPAN. To make sure that C will work is to call the C +function: + + use FindBin; + FindBin::again(); # or FindBin->again; + +In former versions of FindBin there was no C function. The +workaround was to force the C block to be executed again: delete $INC{'FindBin.pm'}; require FindBin; @@ -96,9 +102,9 @@ use File::Spec; %EXPORT_TAGS = (ALL => [qw($Bin $Script $RealBin $RealScript $Dir $RealDir)]); @ISA = qw(Exporter); -$VERSION = "1.43"; +$VERSION = "1.44"; -BEGIN +sub init { *Dir = \$Bin; *RealDir = \$RealBin; @@ -179,5 +185,9 @@ BEGIN } } +BEGIN { init } + +*again = \&init; + 1; # Keep require happy diff --git a/lib/FindBin.t b/lib/FindBin.t index 80ac811..be6f58c 100755 --- a/lib/FindBin.t +++ b/lib/FindBin.t @@ -5,7 +5,7 @@ BEGIN { @INC = -d 't' ? 'lib' : '../lib'; } -print "1..1\n"; +print "1..2\n"; use FindBin qw($Bin); @@ -17,3 +17,9 @@ if ($^O eq 'MacOS') { print "not " unless $Bin =~ m,[/.]lib\]?$,; } print "ok 1\n"; + +$0 = "-"; +FindBin::again(); + +print "not " if $FindBin::Script ne "-"; +print "ok 2\n";