The split/join sequence suggests s/// substitution:
Note that this works regardless of the meta-nature of the separator character/string:c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $string = 'foo+bar+baz+boff'; my $separator = '+'; my $replace = '<REPLACE>'; ;; $string =~ s{ \Q$separator\E }{$replace}xmsg; dd $string; " "foo<REPLACE>bar<REPLACE>baz<REPLACE>boff"
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my $string = 'fooXbarXbazXboff'; my $separator = 'X'; my $replace = '<REPLACE>'; ;; $string =~ s{ \Q$separator\E }{$replace}xmsg; dd $string; " "foo<REPLACE>bar<REPLACE>baz<REPLACE>boff"
Update: See quotemeta; see perlre, perlretut, and perlrequick; see Regexp Quote-Like Operators in perlop for s///.
Give a man a fish: <%-{-{-{-<
In reply to Re: Splitting string based on potentially escaped character
by AnomalousMonk
in thread Splitting string based on potentially escaped character
by clamport
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |