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 23, 2015 02:14
Subject:
Re: Question/suggestion on perlfunc.pod example
Message ID:
CALJW-qF-Od+Se7coPaWpLMbamDmUf6Z-JmjumgPWhQZr+-H_Vg@mail.gmail.com
On Mon, Jun 22, 2015 at 10:12 PM, Eric Brine <ikegami@adaelis.com> wrote:

> On Mon, Jun 22, 2015 at 2:13 AM, Aristotle Pagaltzis <pagaltzis@gmx.de>
> wrote:
>
>> There is nothing inherently erroneous about returning undef
>>
>
> Yes, there is. It prevents errors from being detected and reported
> correctly.
>
>
Previously posted demonstration:

$ echo 'unlink("xxxxxxxxxxx"); undef' >x

$ perl -e'
    my $file = "x";

    # Exact code from the patch follows.
    local ($!, $@);
    my $result = do $file;
    if ($@)
       { warn "Couldn'\''t compile $file or exception thrown: $@" }
    elsif ($! and not defined $result)
       { warn "Couldn'\''t read $file: $!" }
'

Couldn't read x: No such file or directory at -e line 7.

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