Perl string substitution substr

example:

my $text = “This is one heck of a story”;

my $swap = “heck”;

my $replacement = “hell”;

substr($text, index($text, $swap), length($swap), $replacement);

print $text;

Leave a Reply

You must be logged in to post a comment.