use strict; use warnings; use feature 'say'; my $s = "hello world"; # the 4-arg form swaps in new text and returns the old my $old = substr($s, 0, 5, "howdy"); say "$old -> $s";
substr can overwrite a slice