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

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

Thread Previous
From:
schwern
Date:
October 7, 2003 13:00
Subject:
Re: [PATCH bleadperl] Re: Fix broken require() behaviour
Message ID:
20031007125928.B4301@ttul.org
On Mon, Oct 06, 2003 at 08:55:18PM -0400, Rick Delaney wrote:
> > Could somebody submit a patch to update perlfunc/require?
> 
> This probably isn't what you had in mind but it works for me.  :-)

I like this.  That bit of code always seemed to be overdoing it a bit and
exposing too much internal information.


> --- 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


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