Binary "," is the comma operator. In scalar context it evaluates its left argument in void context, throws that value away, then evaluates its right argument in scalar context and returns that value. This is just like C's comma operator. For example:
assigns 3 to $a. Do not confuse the scalar context use with the list context use. In list context, a comma is just the list argument separator, and inserts both its arguments into the LIST. It does not throw any values away.$a = (1, 3);
For example, if you change the previous example to:
you are constructing a two-element list, while:@a = (1, 3);
is calling the function atan2 with two arguments.atan2(1, 3);
The => digraph is mostly just a synonym for the comma operator. It's useful for documenting arguments that come in pairs. It also forces any identifier to its immediate left to be interpreted as a string.
Copyright © 2001 O'Reilly & Associates. All rights reserved.