space is required. Examples are commands for outdenting labels,
B<-ola>, and control keywords, B<-okw>.
-When default values are not used, it is suggested that the value B<n>
-given with B<-ci=n> be no more than about one-half of the number of
-spaces assigned to a full indentation level on the B<-i=n> command.
+When default values are not used, it is highly recommended that the value B<n>
+given with B<-ci=n> be no more than about one-half of the number of spaces
+assigned to a full indentation level on the B<-i=n> command. The reason is
+that discontinuities in the definition and control of continuation indentation
+arise in complex code, and this rule helps to smooth out these discontinuities.
=item B<-sil=n> B<--starting-indentation-level=n>
=item Note: Perltidy does always follow whitespace controls
-The various parameters controlling whitespace within a program are requests which perltidy follows as well as possible, but there are a number of situations where changing whitespace could change program behavior and is not done. Examples are whitespace around bareword symbols and possible filehandles. For example, consider the problem of formatting the following subroutine:
+The various parameters controlling whitespace within a program are requests which perltidy follows as well as possible, but there are a number of situations where changing whitespace could change program behavior and is not done. Some of these are obvious; for example, we should not remove the space between the two plus symbols in '$x+ +$y' to avoid creating a '++' operator. Some are more subtle and involve the whitespace around bareword symbols and locations of possible filehandles. For example, consider the problem of formatting the following subroutine:
sub print_div {
my ($x,$y)=@_;
print $x /$y;
}
-If formatted in this way, the program will not run (at least with recent versions of perl) because the / is assumed to start a quote. In a complex program, there might happen to be a / which terminates the multiline quote without a syntax error, allowing the program to run, but incorrectly.
+If formatted in this way, the program will not run (at least with recent versions of perl) because the $x is taken to be a filehandle and / is assumed to start a quote. In a complex program, there might happen to be a / which terminates the multiline quote without a syntax error, allowing the program to run, but incorrectly.
-Related issues arise with other binary operator symbols, such as + and -, and in older versions of perl there could be problems with ternary operators. So to avoid changing program behavior, perltidy has the simple rule that whitespace around possible filehandles is left unchanged. Likewise, whitespace around barewords is left unchanged.
+Related issues arise with other binary operator symbols, such as + and -, and in older versions of perl there could be problems with ternary operators. So to avoid changing program behavior, perltidy has the simple rule that whitespace around possible filehandles is left unchanged. Likewise, whitespace around barewords is left unchanged. The reason is that if the barewords are defined in other modules, or in code that has not even been written yet, perltidy will not have seen their prototypes and must treat them cautiously.
=item Space between specific keywords and opening paren
qw(if elsif unless while until for foreach switch case given when catch);
@is_blocktype_with_paren{@_} = (1) x scalar(@_);
+ my %is_case_default;
+ @_ = qw(case default);
+ @is_case_default{@_} = (1) x scalar(@_);
+
my $extended_syntax_type = sub {
# check for certain extended syntax variations, and
# default:
# Note that the line 'default:' will be parsed as a label elsewhere.
- if ( $statement_type eq 'case' || $statement_type eq 'default' ) {
+ if ( $is_case_default{$statement_type} ) {
# The type will be the same as a label
$type = 'J';