Here is a simple script that demonstrates the bug:
#!/usr/bin/perl -w
use strict;
use Switch;
# case (make sure Switch.pm applies the filter)
my $x = 4;
my $y = $x/2;
my $filename = "dir/tmp.txt";
print "Look for extra whitespace here --> $filename\n";
__END__
The problem is that the first / is being matched as the start of a regular
expression, rather than as the division operator. The second " is then
matched as the start of a string, rather than the end. This results in the
rest of the code being filtered as if the strings were code and the code
were strings.
Here's the filtered code, with !V{}V! and !Q{}Q! showing the matching of
variables and quote-like strings, respectively.
# line 6
# case (make sure Switch.pm applies the filter)
my!V{ $x}V! = 4;
my!V{ $y}V! = 4!Q{/$x;
my $filename = "dir/}Q!tmp.txt!Q{";
print "}Q!Look for extra whitespace here -->!V{ $filename}V!\n";
The extra whitespace appears as the result of a second bug, which adds an
unnecessary space character to the whitespace that is already there.
Although fixing this would solve the original poster's problem, the module
would still be broken.
The matching of / as the start of a quote-like string happens in
Text::Balanced::_match_quotelike(). Unfortunately, I don't think there's a
simple fix.
This seems to be the fatal flaw of any simplistic attempt at parsing Perl;
it can't be done without keeping track at all times whether a term or an
operator is expected.
Ronald