From: Abhijit Menon-Sen Date: Tue, 7 Oct 2003 03:55:18 +0000 (+0000) Subject: Update perlfunc/require to describe NXDOMAIN caching... er, you X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=209071589ddd827372bd46e1358d1d13f6b4dbcb;p=p5sagit%2Fp5-mst-13.2.git Update perlfunc/require to describe NXDOMAIN caching... er, you know what I mean. p4raw-id: //depot/perl@21417 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index f2e2b97..4d4efc5 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -4054,28 +4054,36 @@ version should be used instead. 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. Has semantics similar to the following -subroutine: +essentially just a variety of C. Has semantics similar to the +following subroutine: 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; + my ($filename) = @_; + if (exists $INC{$filename}) { + return 1 if $INC{$filename}; + die "Compilation failed in require"; + } + 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"; + } + if ($@) { + $INC{$filename} = undef; + die $@; + } elsif (!$result) { + delete $INC{$filename}; + die "$filename did not return true value"; + } else { + return $result; + } } Note that the file will not be included twice under the same specified