[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Bulk substitution with 'EVAL' not working



Any insights into the failings of this code would be greatly appreciated

TIA
Robin

#! perl -w

#=========== declare includes =============
use strict;

use diagnostics-verbose;

#========== declare variables =============
my($file,$newfile,$expr,%regex,@keys);

#============= script body ================

%regex= (I9m => "I be",
	you9re => "you be",
	he9s => "he be",
	she9s => "she be",
	we9re => "we be",
	they9re => "they be",
	there9s=> "there be",
	there9re => "there be",
	am => "be",
	is => "be",
	are => "be"
	);

@keys= keys(%regex);
while (<DATA>) {
    tr/\'/9/;
$expr= join('||',map{"s/\\b$keys[$_]\\W/$regex{$keys[$_]}/"} 0.. $#keys);
eval "sub { $expr}";
die if $@;


print $_;

 }


#========= sub routine separator ===========
__DATA__
I'm glad you're funding this new project, it's the biggest one we've had
this year.  They're also glad you didn't use the company's name in the
newspaper.  I'm sorry I didn't manage to meet you in person.
__END__

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org