in reply to Re: for loops and 'and'
in thread for loops and 'and'

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?