Copying and Substituting Simultaneously

By | August 12, 2010

When the purpose is to search and replace a copy of the string and the intention is to accomplish this in one step then instead of doing this:

$dst = $src;
$dst =~ s/this/that/;

a single step like this will be more concise:

($dst = $src) =~ s/this/that/;

Leave a Reply

Your email address will not be published. Required fields are marked *