develooper Front page | perl.perl5.porters | Postings from October 2003

[PATCH bleadperl] Re: Fix broken require() behaviour

Thread Previous | Thread Next
From:
Rick Delaney
Date:
October 6, 2003 17:56
Subject:
[PATCH bleadperl] Re: Fix broken require() behaviour
Message ID:
20031006205518.A5056@biff.bort.ca
On Tue, Oct 07, 2003 at 12:17:38AM +0530, Abhijit Menon-Sen wrote:
> At 2003-10-06 17:55:16 +0100, steve.hay@uk.radan.com wrote:
> >
> > http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-09/msg01365.html
> 
> Thanks, applied. (#21415)
> 
> Could somebody submit a patch to update perlfunc/require?

This probably isn't what you had in mind but it works for me.  :-)

-- 
Rick Delaney
rick@bort.ca


--- pod/perlfunc.pod.orig	Mon Oct  6 20:45:58 2003
+++ pod/perlfunc.pod	Mon Oct  6 20:49:05 2003
@@ -4054,31 +4054,9 @@
 
 Otherwise, demands that a library file be included if it hasn't already
 been included.  The file is included via the do-FILE mechanism, which is
-essentially just a variety of C<eval>.  Has semantics similar to the following
-subroutine:
+essentially just a variety of C<eval>.
 
-    sub require {
-	my($filename) = @_;
-	return 1 if $INC{$filename};
-	my($realfilename,$result);
-	ITER: {
-	    foreach $prefix (@INC) {
-		$realfilename = "$prefix/$filename";
-		if (-f $realfilename) {
-		    $INC{$filename} = $realfilename;
-		    $result = do $realfilename;
-		    last ITER;
-		}
-	    }
-	    die "Can't find $filename in \@INC";
-	}
-	delete $INC{$filename} if $@ || !$result;
-	die $@ if $@;
-	die "$filename did not return true value" unless $result;
-	return $result;
-    }
-
-Note that the file will not be included twice under the same specified
+The file will not be included twice under the same specified
 name.  The file must return true as the last statement to indicate
 successful execution of any initialization code, so it's customary to
 end such a file with C<1;> unless you're sure it'll return true

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About