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