Ovid has asked for the wisdom of the Perl Monks concerning the following question:
Though I've already reported this bug, along with a fix, I have no idea how the fix works. I'm completely mystified. Here's a small test case:
package NoFilter; use Filter::Simple; FILTER_ONLY code => sub {}; 1;
In other words, it filters nothing.
Here's my test code:
#!/usr/bin/perl use NoFilter; my $buf = <<HERE; / HERE my $buf2 = <<HERE; HERE
This generates the error:
substr outside of string at /usr/local/lib/perl5/5.8.7/Text/Balanced.pm line 70.At first blush it looks like Text::Balanced has a problem with the HERE docs (and historically it has had problems with HERE docs). However, there's a relatively easy fix for this. Opening up Filter::Simple and adding [$_] as the first line of the anonymous subroutine which Filter::Simple::gen_std_filter_for returns:
sub gen_std_filter_for { my ($type, $transform) = @_; return sub { [$_]; # XXX this is the "voodoo" line my $instr;
And the problem mysteriously goes away. I have no frickin' idea why. Any clues? I've emailed thedamian about this but frankly, that's one heck of an embarrassing bug fix since it's "voodoo". Is there something bizarelly simple that I'm overlooking?
Side note: you can also have fun by deleting the "/" line in the first here doc. That generates other fun error messages.
This is perl, v5.8.7 built for darwin-2level. I'm using the latest Text::Balanced and Filter::Simple. I can replicate this problem on OS X and Fedora Core 2. A friend of mine can't replicate this on Perl 5.8.5 Redhat 4.0.
Cheers,
Ovid
New address of my CGI Course.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Filter::Simple bug with here documents (duh!)
by tye (Sage) on Dec 02, 2005 at 06:10 UTC | |
by Ovid (Cardinal) on Dec 02, 2005 at 06:13 UTC | |
by tye (Sage) on Dec 03, 2005 at 03:28 UTC | |
by Ovid (Cardinal) on Dec 03, 2005 at 04:11 UTC | |
Re: Filter::Simple bug with here documents
by GrandFather (Saint) on Dec 02, 2005 at 05:01 UTC | |
by Ovid (Cardinal) on Dec 02, 2005 at 05:09 UTC | |
Re: Filter::Simple bug with here documents
by nexion (Initiate) on Sep 13, 2011 at 18:39 UTC |