From 67a60d80001e9d7cf78d811bf26e3bca28bf20fb Mon Sep 17 00:00:00 2001
From: Steve Hancock <perltidy@users.sourceforge.net>
Date: Fri, 18 Sep 2020 08:53:19 -0700
Subject: [PATCH] modify check to avoid false hash-bang warning

---
 lib/Perl/Tidy/Tokenizer.pm | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm
index 35d18d42..4fbb54d6 100644
--- a/lib/Perl/Tidy/Tokenizer.pm
+++ b/lib/Perl/Tidy/Tokenizer.pm
@@ -824,9 +824,20 @@ sub get_line {
                 )
                 && !$tokenizer_self->[_look_for_hash_bang_]
 
-		# Patch: be sure there is either a slash or the word 'perl'
-		# after the #! before giving a warning.
-                && $input_line =~ /^\#\!\s*(\/|perl)/ 
+                # Try to avoid giving a false alarm at a simple comment. 
+                # These look like valid hash-bang lines:
+
+                #!/usr/bin/perl -w
+                #!   /usr/bin/perl -w
+                #!c:\perl\bin\perl.exe
+
+                # These are comments:
+                #! I love perl
+                #!  sunos does not yet provide a /usr/bin/perl
+
+                # Comments typically have multiple spaces, which suggests
+                # the filter
+                && $input_line =~ /^\#\!(\s+)?(\S+)?perl/ 
               )
             {
 
-- 
2.39.5