Appendix B. Guidelines for parenthesizing code

In this book, we’ve discussed several situations that require the use of parentheses around code. For easy reference, we provide here a complete summary of the cases that come up most frequently in Minimal Perl.

To demonstrate the benefit of adding your own parentheses, the parentheses you effectively get by default are shown in the comments adjoining the code samples.

You should use parentheses:

  1. Around a function’s arguments, to exclude following elements from that argument list:

    print sort (@F), '!';     # Default: print sort (@F, '!');
  2. Around any multi-element argument list for our or chomp:

    chomp ($X, $Y);           # Default: chomp ($X), $Y;
    
    our   ($X, $Y);           # Default: our   ($X), $Y;
  3. Anywhere the higher precedence of ...

Get Minimal Perl now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.