Subject: | # line special comments not correctly processed |
Hello,
perltidy reformats comment lines it should leave intact.
Here is an example script
print add( 3, 4 ), "\n";
print add( 4, 3 ), "\n";
sub add {
my ( $term1, $term2 ) = @_;
# line 1234
die "$term1 > $term2" if $term1 > $term2;
return $term1 + $term2;
}
When reformated with perltidy (-pbp) it gives the following:
print add( 3, 4 ), "\n";
print add( 4, 3 ), "\n";
sub add {
my ( $term1, $term2 ) = @_;
# line 1234
die "$term1 > $term2" if $term1 > $term2;
return $term1 + $term2;
}
The #line comment is meaningful to Perl: if you run both script, you'll
see that the error message is different.
First script:
7
4 > 3 at foo line 1234.
Reformatted script:
7
4 > 3 at foo line 9.
According to perlsyn, the regular expression for matching these special
comment lines is:
/^\# \s*
line \s+ (\d+) \s*
(?:\s("?)([^"]+)\2)? \s*
$/x
Best regards,
-- Philippe Bruhat (BooK)