From: Dave Mitchell Date: Sun, 16 May 2004 15:31:42 +0000 (+0000) Subject: make Text::Balanced skip "case /..../" correctly for Switch.pm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ce94069687f36a0b1d18574193627404340c135f;p=p5sagit%2Fp5-mst-13.2.git make Text::Balanced skip "case /..../" correctly for Switch.pm p4raw-id: //depot/perl@22821 --- diff --git a/lib/Text/Balanced.pm b/lib/Text/Balanced.pm index 820ae25..8b390f7 100644 --- a/lib/Text/Balanced.pm +++ b/lib/Text/Balanced.pm @@ -10,7 +10,7 @@ use Exporter; use SelfLoader; use vars qw { $VERSION @ISA %EXPORT_TAGS }; -$VERSION = '1.95'; +$VERSION = '1.95_01'; @ISA = qw ( Exporter ); %EXPORT_TAGS = ( ALL => [ qw( @@ -583,12 +583,15 @@ sub _match_codeblock($$$$$$$) # NEED TO COVER MANY MORE CASES HERE!!! + # NB 'case' is included here, because in Switch.pm, + # it's followed by a term, not an op + if ($$textref =~ m#\G\s*(?!$ldel_inner) ( [-+*x/%^&|.]=? | [!=]~ | =(?!>) | (\*\*|&&|\|\||<<|>>)=? - | split|grep|map|return + | case|split|grep|map|return | [([] )#gcx) { diff --git a/lib/Text/Balanced/t/extcbk.t b/lib/Text/Balanced/t/extcbk.t index 47b0045..80553ab 100644 --- a/lib/Text/Balanced/t/extcbk.t +++ b/lib/Text/Balanced/t/extcbk.t @@ -13,7 +13,7 @@ BEGIN { # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) -BEGIN { $| = 1; print "1..41\n"; } +BEGIN { $| = 1; print "1..43\n"; } END {print "not ok 1\n" unless $loaded;} use Text::Balanced qw ( extract_codeblock ); $loaded = 1; @@ -64,6 +64,7 @@ __DATA__ # USING: extract_codeblock($str); { $data[4] =~ /['"]/; }; +{ case /^bar\s+\S+/ {\n#+\n}}; # USING: extract_codeblock($str,'<>'); < %x = ( try => "this") >;