develooper Front page | perl.perl5.porters | Postings from June 2015

Re: Question/suggestion on perlfunc.pod example

Thread Previous | Thread Next
From:
Eric Brine
Date:
June 7, 2015 07:06
Subject:
Re: Question/suggestion on perlfunc.pod example
Message ID:
CALJW-qEtJqBDFrDtVj6hV0BYuzO3aZ3CAqxES5Zzxe4w2S=WZA@mail.gmail.com
On Sun, Jun 7, 2015 at 2:56 AM, Eric Brine <ikegami@adaelis.com> wrote:

> On Mon, May 11, 2015 at 6:21 PM, Aristotle Pagaltzis <pagaltzis@gmx.de>
> wrote:
>
>> … but I’m not sure about $! and there may not be any unambiguous signal
>> for that case available.
>>
>
> Yeah, that's wrong. $! can be set even if do succeeds.
>
> That's why you gotta return a true value from files evaluated by do if you
> want to perform error checking.
>
>     $ cat a.pl
>     open(my $fh, "<", "nonexistent");
>
>     $ perl -E'do "a.pl"; say $!'
>     No such file or directory
>
>
Ignore. Tired. The "and not defined $result" will handle that.

But why do recommend making do-evaluated files return defined instead of
true like require-evaluated files?

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