![]() |
|
Perl: the Markov chain saw | |
PerlMonks |
dodgy subby emcb (Beadle) |
on Feb 27, 2002 at 13:30 UTC ( #147893=perlquestion: print w/replies, xml ) | Need Help?? |
emcb has asked for the wisdom of the Perl Monks concerning the following question: Hi, I have written a sub called str_replace. This sub is supposed to work the same as the php function str_replace. Heres the code: sub str_replace { my( $find,$replace,$what ) = @_; $what =~ s/$find/$replace/i; return $what; } I then use this function to find x and replace it with y in z like so: $string = str_replace("Hi", "Hello", "Hello My Name Is Elfyn"); This function only returns 'Hi' instead of 'Hi My name Is Elfyn'. Any help on why fellow monks. Cheers, Elfyn
Back to
Seekers of Perl Wisdom
|
|