sftriman wrote:
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;
}

So if

$x="this could be so cool"

and

$fixhash{"could"}="would";
$fixhash{"COOL"}="awesome";
$fixhash{"beso"}="nope";
$fixhash{"his"}="impossible";

then it would end up

"this would be so awesome"

Have you tryed it? And is it faster than the way you were doing it before? What other ways have you tryed? Did you use the Benchmark module to compare the relative speed of different methods?



John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

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