Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: unless vs. bare block

by ww (Bishop)
on May 10, 2012 at 02:30 UTC ( #969726=note: print w/ replies, xml ) Need Help??


in reply to unless vs. bare block

choroba's answer should get you past your messages; this comment addresses your approach:

unless (open (QTREES, $file)) { print STDERR "WARNING: get_qtrees() can't open $file for filer $fi +ler!\n";

is unnecessarily verbose. In the first example, you could achieve the same end with:

unless (open (QTREES, $file) or warn "get_qtrees() can't open $file for filer $filer!\n");

Similarly, in the second,

open (QTREES, $file) or warn "get_qtrees() can't open $file for filer $filer!\n";


Comment on Re: unless vs. bare block
Select or Download Code
Re^2: unless vs. bare block
by BrowserUk (Pope) on May 10, 2012 at 02:41 UTC
    unnecessarily verbose. In the first example, you could achieve the same end with:

    That's a syntax error:

    $x=1; unless( $x ) or warn 'Erk!';; [syntax error at (eval 11) line 1, near ") or"

    Remember that unless is a 'negative' if, and Perl doesn't support if without a block.

    Ie. In perl, if( cond ) statement must be coded as if( cond ) { statement; }


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

       warn "can't open ... " unless open ...;
        If is necessary to wear a crash helmet when riding a motorbike.
        You don't have to wear a crash helmet when riding a pushbike.

        Both true statements; the presence of 'bike' in both does not make them contradictory.

        Ditto: unless( cond ) { statement; } and statement unless cond;.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://969726]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-08-27 23:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (253 votes), past polls