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

Question/suggestion on perlfunc.pod example

Thread Next
From:
Glenn Golden
Date:
May 11, 2015 21:20
Subject:
Question/suggestion on perlfunc.pod example
Message ID:
20150511212035.GC581@huh.zplane.com
Regarding this example from perlfunc.pod, pertaining to "do":

    ===================================================================
    for $file ("/share/prog/defaults.rc", "$ENV{HOME}/.someprogrc")
    {
        unless ($return = do $file) {
            warn "couldn't parse $file: $@" if $@;
            warn "couldn't do $file: $!"    unless defined $return;
            warn "couldn't run $file"       unless $return;
        }
    }
    ===================================================================

Is the final "unless $return" necessary? 

Also: The meaning of the word 'run' in the warning text "couldn't run $file"
seems unclear.  If my understanding of the accompanying doc text is correct, 
seems like it should be possible to reach that warning clause only if the
final expression resulting from evaluating $file is false.  If this reading
is correct, would it make sense to change the warning text to something more
directly interpretable by the reader, e.g. "final expression evaluating $file
is false"?

If so, I'll be happy to submit a doc patch for either/both of these changes,
but wanted to first ask if my understanding of this was even correct.

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