B
Bill Keese
You can think of the s/// operator as a function taking three
arguments: pattern, replacement, and input-string. This function
modifies input-string according to pattern and replacement. But is
there any similar function which returns a new string, rather than
updating input-string?
For example, instead of doing this:
($newLetter = $oldLetter) =~ s/Mister/Mr./;
Can I do something like this?
$newLetter = ($oldLetter ~ s/Mister/Mr./) ;
This is similar to java's replace function:
newLetter = oldLetter.replace("Mister", "Mr.");
Thanks,
Bill
arguments: pattern, replacement, and input-string. This function
modifies input-string according to pattern and replacement. But is
there any similar function which returns a new string, rather than
updating input-string?
For example, instead of doing this:
($newLetter = $oldLetter) =~ s/Mister/Mr./;
Can I do something like this?
$newLetter = ($oldLetter ~ s/Mister/Mr./) ;
This is similar to java's replace function:
newLetter = oldLetter.replace("Mister", "Mr.");
Thanks,
Bill