in reply to Search and replace logic

How about using a single regular expression?
my $str = "florence, defense"; $str =~ s/n(c|s)e/$1 eq 'c'?'nse':'nce'/ge; print "$str\n";
And the output is -
florense, defence
which is just as expected.

Replies are listed 'Best First'.
Re: Re: Search and replace logic
by carric (Beadle) on Nov 19, 2003 at 07:42 UTC
    This did what I was looking for.

    THANKS!!!