Click here to get back home

Filter::Simple bug?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Filter::Simple bug? Lasse Hillerøe Petersen 12-21-2004
`--> Re: Filter::Simple bug? Lasse Hillerøe ...12-28-2004
Posted by Lasse Hillerøe Petersen on December 21, 2004, 9:54 pm
Please log in for more thread options
I have been playing a bit with Filter::Simple.

I made the following module, Perlgol.pm, 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/:=/=/g;
s/def (.+?) = fun((.*?))/sub $1 { my($2) = @_;/g;
# s/let (.+?) = (.+?);/my($1) = ($2);/g;
s/nuf/}/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/od/}/g;
s/if (.+?) then/if ($1) {/g;
s/else (.+?) then/} elsif ($1) {/g;
s/else/} else {/g;
s/fi/}/g;

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

1;

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);
nuf

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

exit"
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
away?

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")


Posted by Lasse Hillerøe Petersen on December 28, 2004, 6:04 am
Please log in for more thread options
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:
salt
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
celery
garlic
½ 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




Similar ThreadsPosted
Printing xlated output of Filter::Simple ? November 13, 2004, 6:15 pm
opendocument -> csv filter ? September 20, 2006, 10:28 am
Email::Filter hello world August 15, 2004, 3:36 pm
where can download Filter::netcrypt February 22, 2005, 9:55 pm
Perl Tk::FBox and filter argument January 30, 2007, 2:40 pm
can apache::filter work with virtual location? July 28, 2007, 10:36 pm
XML::Simple Help? April 23, 2005, 5:09 pm
Help in XML::Simple July 1, 2005, 9:12 pm
Getopt::Simple V 1.47 July 29, 2004, 7:18 am
Simple question September 15, 2005, 4:17 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap