The quick answer is that and binds less tight than parentheses or &&. The long answer is to first look at what Perl sees:

>perl -MO=Deparse -e "$File::Find::prune= not $recurse and ($File::Fin +d::dir ne $File::Find::topdir);" $File::Find::dir ne $File::Find::topdir if $File::Find::prune = !$recu +rse;

So we now see that Perl doesn't group what "we" see as an expression together, but splits it in two. To group together what we want together, we can use parentheses (like you did), or the sigil-versions of operators, which do bind tighter:

>perl -MO=Deparse -e "$File::Find::prune= not $recurse && ($File::Find +::dir ne $File::Find::topdir);" $File::Find::prune = !($recurse && $File::Find::dir ne $File::Find::to +pdir);

Having the two kinds of operators isn't all weird, because the more lax binding operators are incredibly convenient when writing code that depends on the return value of statements when you don't want parentheses:

open my $fh, $file or die "Couldn't open '$file': $!";

If or did bind as close as ||, then you would need parentheses:

open (my $fh, $file) || die "Couldn't open '$file': $!";

Otherwise, Perl interprets things "wrong again", and groups $filename || die ... together:

>perl -MO=Deparse -e "open my $fh, $filename || die qq(couldn't open $ +filename: $!)" open my $fh, $filename || die("couldn't open ${filename}: $!"); -e syntax OK >perl -MO=Deparse -e "open my $fh, $filename or die qq(couldn't open $ +filename: $!)" die "couldn't open ${filename}: $!" unless open my $fh, $filename; -e syntax OK

In reply to Re: Need explanation for: useless use of string ne in void context by Corion
in thread Need explanation for: useless use of string ne in void context by Skeeve

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.