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

Re: Core modules w/o "1;" [Was: Re: Pod::Man has no "1;"...]

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
March 28, 2003 23:39
Subject:
Re: Core modules w/o "1;" [Was: Re: Pod::Man has no "1;"...]
Message ID:
20030329073923.GB2630@windhund.schwern.org
On Sat, Mar 29, 2003 at 04:15:58PM +0900, Dan Kogai wrote:
> perldoc -f require says;
> >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;
> >}
> 
> Therefore it is perl 5.8.0 that is behaving correctly.  And "eval 
> q(require Module)" still works since  It does not kill perl itself.

By that logic, "require Module" should die, but its not.

The behavior of:

    # loads Pod::Man fine, doesn't die.
    require Pod::Man;

and

    # doesn't load Pod::Man, dies.
    eval q{require Pod::Man};  die $@ if $@;

and

    # loads Pod::Man fine, doesnt' die.
    eval q{require Pod::Man; 1};  die $@ if $@;

should be consistent.  In 5.8.0 they are not.  There *is* a bug in eval
STRING here.

Here's another interesting data point:

$ perl5.8.0 -wle 'print require Pod::Man;'
142
$ perl5.8.0 -wle 'print eval q[require Pod::Man];  print $@'
142

So it *is* returning a true value.  Not sure where its coming from, but its
there.  Its also bizarre that "print eval q[require Pod::Man]" is different
from "eval q[require Pod::Man]" in that the module is loaded and $@ is not
set.

Slapping "1;" on the end of modules might be useful, that's a different
debate, but it will not fix this bug.


--
You're smoother than a tunnel of shining sorrow.

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