[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
15.5.18.7 When To Use Parentheses
In Perl, parentheses around function arguments are mostly optional.
xgettext
will always assume that all
recognized keywords (except for hashes and hash references) are names
of properly prototyped functions, and will (hopefully) only require
parentheses where Perl itself requires them. All constructs in the
following example are therefore ok to use:
print gettext ("Hello World!\n"); print gettext "Hello World!\n"; print dgettext ($package => "Hello World!\n"); print dgettext $package, "Hello World!\n"; # The "fat comma" => turns the left-hand side argument into a # single-quoted string! print dgettext smellovision => "Hello World!\n"; # The following assignment only works with prototyped functions. # Otherwise, the functions will act as "greedy" list operators and # eat up all following arguments. my $anonymous_hash = { planet => gettext "earth", cakes => ngettext "one cake", "several cakes", $n, still => $works, }; # The same without fat comma: my $other_hash = { 'planet', gettext "earth", 'cakes', ngettext "one cake", "several cakes", $n, 'still', $works, }; # Parentheses are only significant for the first argument. print dngettext 'package', ("one cake", "several cakes", $n), $discarded;
This document was generated on June 7, 2014 using texi2html 5.0.