my $value = "abcde"; sub attack { $_[0] = "x" } attack($_) for substr($value, 2, 1); print "$value\n"; # prints "abxde\n"