From c00059afab9fd428ca63abdcabbc617faf56b4c3 Mon Sep 17 00:00:00 2001
From: Steve Hancock <perltidy@users.sourceforge.net>
Date: Sat, 3 Jul 2021 18:25:48 -0700
Subject: [PATCH] Check for side comment within package statement

---
 lib/Perl/Tidy/Tokenizer.pm |  3 ++-
 local-docs/BugLog.pod      | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm
index b0e3676d..1be21abe 100644
--- a/lib/Perl/Tidy/Tokenizer.pm
+++ b/lib/Perl/Tidy/Tokenizer.pm
@@ -6601,7 +6601,8 @@ sub do_scan_package {
         # knows that the number is in a package statement.
         # Examples of valid primitive tokens that might follow are:
         #  1235  . ; { } v3  v
-        if ( $next_nonblank_token =~ /^([v\.\d;\{\}])|v\d|\d+$/ ) {
+        # FIX: added a '#' since a side comment may also follow
+        if ( $next_nonblank_token =~ /^([v\.\d;\{\}\#])|v\d|\d+$/ ) {
             $statement_type = $tok;
         }
         else {
diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod
index 41041242..567286e9 100644
--- a/local-docs/BugLog.pod
+++ b/local-docs/BugLog.pod
@@ -2,6 +2,17 @@
 
 =over 4
 
+=item B<Check for side comment within package statement>
+
+Testing with randomly placed side comments caused perltidy to produce an incorrect
+warning when a side comment is placed before the end of a package statement:
+
+    package double # side comment
+    ;
+
+This update fixes this.
+3 Jul 2021.
+
 =item B<Fix problem with -comma-arrow-breakpoint=n flag>
 
 Testing revealed a formatting irregularity which was caused when the flag
-- 
2.39.5