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 06:56
Subject:
Re: Question/suggestion on perlfunc.pod example
Message ID:
CALJW-qGWAUH2p-OM9MXpZUOmjhs1K0u9LXBQOoEyYyteB04NDA@mail.gmail.com
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

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