I am wrong. See below. A key question for me is what does or give scalar context to when it is evaluated in list context. I reproduce the results of a test I ran. The results? Mindboggling.
sub leftt { wantarray ? print "Left is list\n" : print "Left is scalar\n"; return 1; } sub rightt { wantarray ? print "Right is list\n" : print "Right is scalar\n"; return 1; } sub leftf { wantarray ? print "Left is list\n" : print "Left is scalar\n"; return 0; } sub rightf { wantarray ? print "Right is list\n" : print "Right is scalar\n"; return 0; } print "true or true \n"; @test = leftt() or rightt(); print "\@test = @test\n"; print "true or false\n"; @test = leftt() or rightf(); print "\@test = @test\n"; print "false or true\n"; @test = leftf() or rightt(); print "\@test = @test\n"; print "false or false\n"; @test = leftf() or rightf(); print "\@test = @test\n"; __END__ Output: true or true Left is list @test = 1 true or false Left is list @test = 1 false or true Left is list @test = 0 false or false Left is list @test = 0
Looks like left is always evaled in list, and right is never even checked. But then where does the scalar issue of .. come in.. argh!

UPDATE: Swat! Damn bugs. Sorry... The results are the same though. Why does this happen?


UPDATE^2: Precedence problem. the tests were evaluating as (@test = left()) or right(). Deparse++ :)


Who is Kayser Söze?

In reply to Re: Re: for loops and 'and' by jweed
in thread for loops and 'and' by Anonymous Monk

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.