2009/12/20 sftriman <dal...@gmail.com>:
> I've been wondering for a long time... is there a slick (and hopefully
> fast!) way
> to do this?
>
> foreach (keys %fixhash) {
>    $x=~s/\b$_\b/$fixhash{$_}/gi;
> }

You can do a global substitute of the sentence and see if they match
any key in the hash. i.e.:

$x =~ s/\b([A-Za-z]+)\b/$fixhash{$1} || $fixhash{uc($1)} ||  $1/egi;

Which, in some circles, might be considered slick. As to fast, well,
this *is* Perl.


-- 
Erez

"The government forgets that George Orwell's 1984 was a warning, and
not a blueprint"
http://www.nonviolent-conflict.org/ -- http://www.whyweprotest.org/

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to