From: Steve Hancock Date: Sun, 13 Jun 2021 13:55:11 +0000 (-0700) Subject: add 'perltidy_hide.pl' for testing issue in git #65 X-Git-Tag: 20210402.01~13 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=89748917f0ebfe7c7633f45b3a8cfc95bd5d607d;p=perltidy.git add 'perltidy_hide.pl' for testing issue in git #65 --- diff --git a/examples/perltidy_hide.pl b/examples/perltidy_hide.pl new file mode 100755 index 00000000..a98a5a1d --- /dev/null +++ b/examples/perltidy_hide.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl +package main; +use Perl::Tidy; + +=pod + +Hide sections of as script from perltidy which are between special comments, +like this: + +#<>V' is hidden from perltidy but seen by perl + +#>>V + +This works by converting #<>V into =cut before +processing, and then converting back after processing. + +This was created for issue git #65. + +=cut + +my $arg_string = undef; + +exit Perl::Tidy::perltidy( + argv => $arg_string, + prefilter => sub { + $_ = $_[0]; + s/^(#<>V\b.*)$/=cut $1/gm; + return $_; + }, + postfilter => sub { + $_ = $_[0]; + s/^=pod (#<>V\b)/$1/gm; + return $_; + }, +);