Make Switch.pm skip POD like perl does
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sun, 28 Dec 2008 22:30:57 +0000 (23:30 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 30 Mar 2009 17:13:37 +0000 (18:13 +0100)
Patch provided by Daniel Klein <danielklein-à-airpost.net> :

  It also doesn't check for invalid POD which gets ignored by the
  compiler anyway.

Seems that Damian had a POD parser in mind when he devised those
regular expressions, but perl only looks for =cut followed by a
non-letter.

(cherry picked from commit 39bcdda02ea582e7bdf8b0cf2e7186e89c6baea9)

lib/Switch.pm

index 4dbdeae..a12e6d6 100644 (file)
@@ -72,15 +72,9 @@ sub is_block
        return !$ishash;
 }
 
-
-my $EOP = qr/\n|\Z/;
-my $CUT = qr/\n=cut.*$EOP/;
-my $pod_or_DATA = qr/ ^=(?:head[1-4]|item) .*? $CUT
-                    | ^=pod .*? $CUT
-                    | ^=for .*? $EOP
-                    | ^=begin \s* (\S+) .*? \n=end \s* \1 .*? $EOP
-                    | ^__(DATA|END)__\n.*
-                    /smx;
+my $pod_or_DATA = qr/ ^=[A-Za-z] .*? ^=cut (?![A-Za-z]) .*? $
+                   | ^__(DATA|END)__\n.*
+                   /smx;
 
 my $casecounter = 1;
 sub filter_blocks