Thank you Rob. I am aware of that actually. To state my confusion, I wil get a better example:
For the following code, sub fun { print "fun(@_) "; } fun 1, fun ''b" | "c", 1; The output looks like: fun(c,1) fun(1,1) *but* the precedence of the operators used is as: comma operator, list operator, bitwise string operator. *so* the commas and list operators should be evaluated before the pipe gets a chance. so the right hand side of the pipe is discarded, passing only "b" to the funciton because the list operator is evaluated before the pipe. But this doesn't seem to be happening! like how in code: $a = 1, 2; 2 is discarded because comma has lower precedence than the assignment operator. Thanks, Joel On Mar 22, 1:10 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > Joel wrote: > > > > > > > > > > Can you tell me the sequence of events that happen (internally in perl > > during parsing) for the following code: > > > sub fun > > { > > print @_; > > } > > > fun fun (1), fun 2, fun (3); > > > I am particularly interested in the comma operator, in the above code, > > as I understand it > > (1) first the list operations (which have highest precedence because > > of parantheses) will execute first printing "13". > > (2) then the comma between fun(1) and fun 2 is evaluated, once this > > happens, is the list operation ( fun 2, fun(3) ) evaluated or is the > > comma between 2 and fun(3) evaluated? > > I suspect you are forgetting that fun() itself returns the success > status of the print() function, introducing additional 1s into the > output. Look: > > local $" = ','; > > sub fun { > print "fun(@_) "; > } > > fun fun ('a'), fun 'b', fun ('c'); > > **OUTPUT** > > fun(a) fun(c) fun(b,1) fun(1,1) > > The line > > fun fun ('a'), fun 'b', fun ('c'); > > parses as > > fun(fun('a'), fun('b', fun('c'))); > > and each parameter list is evaluated from left to right, hence the order > shown by the code's output. > > HTH, > > Rob- Hide quoted text - > > - Show quoted text - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/