From: Steve Hancock Date: Wed, 24 Jun 2020 13:17:19 +0000 (-0700) Subject: add 'ref' to a hash to fix git #32, misparse of a ? as quote delimiter X-Git-Tag: 20200619.02~16 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4ddad0cdb5be938b33ebae99ddf9bc5eb715d600;p=perltidy.git add 'ref' to a hash to fix git #32, misparse of a ? as quote delimiter --- diff --git a/bin/perltidy b/bin/perltidy index 7b795f23..07b43704 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -1100,7 +1100,7 @@ Suppose the user requests that / signs have a space to the left but not to the r print $x /$y; } -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. +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 not as intended. 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. diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 2e15f75a..74ce6966 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -2075,9 +2075,11 @@ sub prepare_for_a_new_file { elsif ( $expecting == UNKNOWN ) { # In older versions of Perl, a bare ? can be a pattern - # delimiter. Sometime after Perl 5.10 this seems to have - # been dropped, but we have to support it in order to format - # older programs. For example, the following line worked + # delimiter. In perl version 5.22 this was + # dropped, but we have to support it in order to format + # older programs. See: + ## https://perl.developpez.com/documentations/en/5.22.0/perl5211delta.html + # For example, the following line worked # at one time: # ?(.*)? && (print $1,"\n"); # In current versions it would have to be written with slashes: @@ -8044,6 +8046,7 @@ BEGIN { eval lc pop + ref shift uc undef