in reply to Re: substr and strings on the outside
in thread substr and strings on the outside
This works fine for me:
use strict; use warnings; my $f= " Joe Bloggs, 1615 Thislane Street\n"; substr($f, 20, 12345, "This is a new longer address\n"); print $f;
substr has no problems making the string longer. It's inserting new bytes where the first new byte is beyond the end of the original scalar that causes errors. So the following fails with the error message you mention:
substr($f, length($f) + 10, 12345, "This is a new longer address\n");
|
|---|