in reply to Re: Splitting string based on potentially escaped character
in thread Splitting string based on potentially escaped character

It is unnecessary and extremely annoying for you to provide your path and to wrap the code the way you do, consider: Invocation:
perl -wMstrict -MData::Dump -le
Code:
my $string = 'fooXbarXbazXboff'; my $separator = 'X'; my $replace = '<REPLACE>'; $string =~ s{ \Q$separator\E }{$replace}xmsg; dd $string;
Yields
foo<REPLACE>bar<REPLACE>baz<REPLACE>boff
So much more useful for the OP and no additional effort on your behalf.