, , ,
xx\ny
. , , . , "$replaceStr", , xx\nyy . (, , Perl, , Module::Names.)
eval - /e .
my $str = '<b>';
my $r = 'xx\ny';
$str =~ s/b/$r/;
xx\ny, .
/e , , , $r, xx\ny .
, /e, , /e, eval . , qq{ .. }, .
$str =~ s/b/qq{"$r"}/ee
perl qq{"$r"} , "xx\nyy", , - , 'xx' . "\n" . 'yy'.
use strict;
use warnings;
my $s = '<b>';
my $r = 'xx\nyy';
$s =~ s/b/qq{"$r"}/ee;
print $s;
<xx
yy>
, , ,
my $r = 'xx\n"yy"'
, , .
, String::Escape, unbackslash, \n ( escape-) "\n". , , , .
, , unbackslash $r, , . $r - , .
, String::Escape,
use strict;
use warnings;
use String::Escape 'unbackslash';
my $s = '<b>';
my $r = 'xx\nyy';
$s =~ s/b/unbackslash $r/e;
print $s;
.
, String::Escape. Path::Tiny, , inplace-edit Perl, perlvar.
use utf8;
use strict;
use warnings;
use 5.010;
use open qw/ :std :utf8 /;
use String::Escape qw/ unbackslash /;
our @ARGV;
my ($file, $search, $replace) = @ARGV;
print "Search String: $search\n";
print "Replace String: $replace\n\n";
@ARGV = ($file);
$^I = '';
while (<>) {
s/$search/unbackslash $replace/eg;
print;
}