in reply to Replacing everything in between using s///;

First, you'll escape all special characters in $first and $last, or use \Q...\E. (I can't believe noone else mentioned this.)

Secondly, if you match $first and $last, you need to reinsert them:

$string =~ s/(\Q$first\E).*?(\Q$last\E)/$1$reserve$2/;

or use a zero-width assertion:

$string =~ s/(?<=\Q$first\E).*?(?=\Q$last\E)/$reserve/;

Since you're constant strings, you could also use index instead of regexp:

$first_start = index($_, $first); if ($first_start >= 0) { $first_end = $first_start + length($first); $last_start = index($_, $last, $first_end); if ($last_start >= 0) { substr($_, $first_end, $last_start, $replace); } }