A
Arne
Trying to make a simple replacement of strings I spent some hours
resulting in this:
#!/usr/bin/perl -w
#use strict;
$_ = "Just {Test4*4}";
#my $old = "{Test4*4}"; #(i) normal double quoted match
my $old = "\{Test4\*4\}"; #(ii) escaping meta chars
#my $old = '{Test4*4}'; #(iii) using single quotes
my $new = "okay";
s/$old/$new/;
print "$_\n";
It should just demonstrate how to substitute a substring containing
meta chars (e.g. { or *). I had expected that avoiding interpolation
by escaping would help. But even single quote strings aren't better.
Tell me why I am such a fool. would appreciate.
Arne
resulting in this:
#!/usr/bin/perl -w
#use strict;
$_ = "Just {Test4*4}";
#my $old = "{Test4*4}"; #(i) normal double quoted match
my $old = "\{Test4\*4\}"; #(ii) escaping meta chars
#my $old = '{Test4*4}'; #(iii) using single quotes
my $new = "okay";
s/$old/$new/;
print "$_\n";
It should just demonstrate how to substitute a substring containing
meta chars (e.g. { or *). I had expected that avoiding interpolation
by escaping would help. But even single quote strings aren't better.
Tell me why I am such a fool. would appreciate.
Arne