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? Thanks, Joel On Mar 20, 9:21 pm, [EMAIL PROTECTED] (Chas. Owens) wrote: > On Thu, Mar 20, 2008 at 11:28 AM, Joel <[EMAIL PROTECTED]> wrote: > > > > my_function "foo", "bar"; > > > > > my_function is a list operator which has a very low precedence so the > > > > parentheses are not required. > > > > Sometimes, i.e. if the sub is not predeclared, they are required. > > > yes this is true, because perl doesn't know that my_function is > > actually a function call when it doesn't see it predeclared.. > > > I have another question, why are function calls without parantheses > > called list operators, is there no difference between the two? > > why isn't a function call with parantheses called a list operator too? > > snip > > Not all subroutines are list operators. For instance, > > sub square ($) { $_[0] ** 2 } > > is a named unary operator. > > from perldoc perlop* > Actually, there aren't really functions in this sense, just > list operators and unary operators > behaving as functions because you put parentheses around the arguments. > > *http://perldoc.perl.org/perlop.html#Terms-and-List-Operators-(Leftward) > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/