Perl programs tend to be filled with punctuation. Excessive punctuation makes programs less readable, and wise programmers will take advantage of features that make it possible to write programs with considerably less punctuation. For example, Perl allows user -written functions to use the same ampersand-less syntax that built-in functions do:
Different kinds of function call syntax
The traditional & syntax has its usesit's the only way to call a subroutine whose name is a keyword, for example, &for . The list operator syntax, without ampersand or parentheses, works if the definition or declaration of the function appears lexically before the function call. This is generally fine, but there are some pitfalls:
Another helpful feature is the addition of the super-low precedence short-circuit logical operators and and or . (There's also the less exciting not and the generally useless xor .) These allow you to get rid of parentheses in a variety of situations:
Use and and or instead of && and .
Remember that you can always eliminate a semicolon preceding a closing brace . This is probably a good idea in blocks that consist of a single statement, especially when such a block is used as an argument to map , grep , do , eval , or the like:
One more way to get rid of extra parentheses and braces is to use the statement modifier, or " backwards conditional," syntax. It's handy once you get used to it: