List Operators (Rightward)

List Operators (Rightward)

On the right side of a list operator, the comma has very low precedence, such that it controls all comma-separated expressions found there. The only operators with lower precedence are the logical operators "and" , "or" , and "not" , which may be used to evaluate calls to list operators without the need for parentheses:

open HANDLE, "< :utf8", "filename" or die "Can't open: $!\n";

However, some people find that code harder to read than writing it with parentheses:

open(HANDLE, "< :utf8", "filename") or die "Can't open: $!\n";

in which case you might as well just use the more customary "||" operator:

open(HANDLE, "< :utf8", "filename") || die "Can't open: $!\n";

See also discussion of list operators in Terms and List Operators (Leftward).

doc_perl
2016-12-06 03:21:09
Comments
Leave a Comment

Please login to continue.