in reply to Re: using a hash to do substitution?
in thread using a hash to do substitution?
no_slogan's regex trick is very nice (++), however, I've been led to believe that lots of ors (the | char) in a regex can blow out the stack (or take a long time) because of the back tracking required. Can any more adept monks comment on this?
The other more brute force less pretty way to solve the problem is:
foreach $key (keys %hash) { $text =~ s/$key/$hash{$key}/eg; }
-I went outside... and then I came back in!!!!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: using a hash to do substitution?
by tachyon (Chancellor) on Jun 14, 2001 at 11:02 UTC | |
Re: Re: Re: using a hash to do substitution?
by MeowChow (Vicar) on Jun 14, 2001 at 11:12 UTC |
In Section
Seekers of Perl Wisdom