M
Michele Dondi
TJM> $line =~ s/\\\\/&backslash;/g; # translate literal backslashes [cut]
TJM> __DATA__
TJM> a=b=c
TJM> a\=b=c
TJM> a\\=b=c
TJM> a\\\=b=c
TJM> ----------------------------
MD> I like to be sure thus instead of adding "some other large number" I
MD> actually *find* something that *can't* be there:
MD> my $delim = "&". (sort @delims = $line =~ /&(\0+);/)[-1] . "\0;";
MD> $line =~ s/\\\\/$delim;/g; # translate literal backslashes
MD> # ...
Surely there's a CPAN module to do this... Or 10...
From the docs of Encode::Escape, there's also String::Escape,
Unicode::Escape, TeX::Encode, HTML::Mason::Escape,
Template:lugin::XML::Escape, URI::Escape.
There could be even more: each of them would make maximum sense in the
context it would be actually designed for, non of which seems to be
the case for the OP's requirement. That TJM chose (reasonably!) a
"markup" resemblink that appropriate for one of those *::Escape
thingies is a whole another matter. More precisely, it could get
ridiculously improbable, but if those modules don't "find something
that's surely NOT there" then one could actually concoct up an example
data file that would make them fail on it. And I was illustrating the
general concept and technique of "finding something that's surely NOT
there" which I (i) still support now (ii) FOR ONCE don't necessarily
advocate the use of an existing module for, given that it can be
expressed in an excessively big number of ways with a simple statement
too. (Here I chose sort() because the overhead is minimum, but it may
well have been reduction, and so on...)
Michele