in reply to escape each backslash of each array element
$_=join qq#\\\\#,split(/\\/,$_,-1);
You need to put the substitution into a loop until no more substitutions are made.
The problem with that approach is that (for me) that loops infinitely, as it discovers more "\\" replacing "\".
I'm sure a wiser monk will provide the appropriate elegant hack.
Here is another approach, using substitution:
Update:Struck incorrect statements, and improved second sample code.>perl -e "my @s=qw(\\\\c\\c\\ d\\d aa bb); for my $x(@s){($y=$x)=~ s#( +\\+)#$1$1#g;print qq{$y=$x;\n}}" \\\\c\\c\\=\\c\c\; d\\d=d\d; aa=aa; bb=bb;
Syntactic sugar causes cancer of the semicolon. --Alan Perlis
|
|---|