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

Re: [MacPerl] Bulk substitution with 'EVAL' not working



At 19.19 -0700 2000.06.29, by way of Vicki Brown wrote:
>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);

With ||, the statement will finish as soon as one of them returns true.

  join ';'


>eval "sub { $expr}";

This just creates a sub, it doesn't execute anything.

  eval $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

-- 
Chris Nandor       |     pudge@pobox.com      |     http://pudge.net/
Andover.Net        | chris.nandor@andover.net | http://slashcode.com/

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