Q:

Perl remove substring in the middle of a string

How can I remove (or replace by nothing) the 4th and 5th character of my string, in this case number 5 and number 6, to go from this:
123456789

to this:
1234789

A:

You can just replace it with substr.
use 5.12;
my $foo = '123456789';
substr $foo, 4, 2, q{};

say $foo; # prints 1234789

A:

You can use substr() as lvalue
my $str = "123456789";
substr($str, 4, 2) = "";

print $str;

output
1234789

