Filter::Simple bug?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have been playing a bit with Filter::Simple.

I made the following module,, sort of Bournegol for Perl, and
it's behaving weird:
package Perlgol;

use Filter::Simple;
$debug = 1;

FILTER_ONLY code => sub {
        print STDERR "Filtering: $_" if $debug;
        s/def (.+?) = fun\((.*?)\)/sub $1 { my($2) = \@_;/g;
#       s/let (.+?) = (.+?);/my($1) = ($2);/g;
        s/while (.+?) do/while ($1) {/g;
        s/until (.+?) do/until ($1) {/g;
        s/for (.+?) in (.+?) do/for my $1 ($2) {/g;
        s/for (.+?) from (.+?) to (.+?) do/for($1 = $2 ; $1 <= $3 ;
($1)++) {/g;
        s/for (.+?) from (.+?) to (.+?) by (.+?) do/for($1 = $2 ; $1 <=
$3 ; ($1)+=($4)) {/g;
        s/if (.+?) then/if ($1) {/g;
        s/else (.+?) then/} elsif ($1) {/g;
        s/else/} else {/g;

        print STDERR "Transform: $_" if $debug;


Should be straightforward: The following testcase:
#! /usr/pkg/bin/perl -w
use strict;
use Perlgol;

def min = fun($x,$y)
    return $x if $x < $y ;
    return ($y);

works fine.
However, if I add a line at the end, like "exit;", I get:
easy:~/src $ perl testcase 2>&1 | cat -v
def min = fun($x,$y)
    return $x if $x < $^\^@^@^@^@^\
sub min { my($x,$y) = @_;
    return $x if $x < $^\^@^@^@^@^\
Filtering: Transform: syntax error at testcase line 10, near "nuf

Missing right curly or square bracket at testcase line 10, at end of line
Execution of testcase aborted due to compilation errors.

(The ^@ nul bytes shown by cat -v are from the way Filter::Simple
masks quotelike stuff.)

If I systematically replace '$y' with '$z', everything works fine again.
It is as if something causes Filter::Simple to misinterpret y
as the y///-operator (a synonym for tr/// for sed-lovers), which is
quotelike. I really can't understand why adding an otherwise harmless
line can cause this error.

Is there anyone out there who can tell me what I'm doing wrong (I know
its a primitive way to do it, I should check word-boundaries etc, but so
far this is just a rough toy), or should I mail Damian Conway straight

I have tested this with perl5.8.3, 5.8.4 og 5.8.5. Filter::Simple being
a standard module, I also tried the CPAN version, 0.79. No difference.

Lasse Hillerøe Petersen     | "I met someone who looks a lot like you,
----------------------------+  she does the things you do;
         No Windows         |  but she is an IBM"
        = No virus          | (Jeff Lynne, "Yours truly 2095")

Re: Filter::Simple bug?

by loosening from the edges,
   then stripping off.
Season generously, rubbing the mixture into the baby?s flesh.
Place 1 quart water in a baking pan, the meat on a wire rack.
Bake uncovered in 250° oven for 1½ hours.
When browned, remove and glaze,
   return to oven and bake 20 minutes more to form a glaze.
Cut ribs into individual pieces and serve with extra sauce.

Fresh Sausage

If it becomes necessary to hide the fact that you are eating
human babies, this is the perfect solution.
But if you are still paranoid, you can substitute pork butt.

5 lb. lean chuck roast
3 lb. prime baby butt
2 tablespoons each:
   black, white and cayenne peppers
   celery salt
   garlic powder
   parsley flakes
   brown sugar
1 teaspoon sage
2 onions
6 cloves garlic
bunch green onions, chopped

Cut the children?s butts and the beef roast into pieces
   that will fit in the grinder.
Run the meat through using a 3/16 grinding plate.
Add garlic, onions and seasoning then mix well.
Add just enough water for a smooth consistency, then mix again.
Form the sausage mixture into patties or stuff into natural casings.

Stillborn Stew

By definition, this meat cannot be had altogether fresh,
but have the lifeless unfortunate available immediately after delivery,
or use high quality beef or pork roasts (it is cheaper and better to
cut up a whole roast than to buy stew meat).

1 stillbirth, de-boned and cubed
¼ cup vegetable oil
2 large onions
bell pepper
½ cup red wine
3 Irish potatoes
2 large carrots

This is a simple classic stew that makes natural gravy,
thus it does not have to be thickened.
Brown the meat quickly in very hot oil, remove and set a

Site Timeline