D
Dave Walden
Hi,
Can someone tell me how I can obtain functionality like
$str =~ s/$a/$b/g;
where $a and $b contain strings and where instance of the the literal
string contained in $a are replaced by the literal string in $b
*without* regular expression interpretation. In other words, in the
following
my $str = 'moo \foo.* zoo';
my $a = ' \foo.*';
my $b = ' $';
$str =~ s/$a/$b/g;
I would like the value in $str to end up being 'moo $ zoo' while
allowing me to avoid having to escape in all the regex control
characters in the arguments to s///. Is there some qualifier I can use
to turn off regular expression interpretation in the arguments to s///
or some other way I can easily accomplish this without coding a new
subtroutine which takes the three arguments $str, $a, and $b and does
what I want?
Thanks, Dave
Can someone tell me how I can obtain functionality like
$str =~ s/$a/$b/g;
where $a and $b contain strings and where instance of the the literal
string contained in $a are replaced by the literal string in $b
*without* regular expression interpretation. In other words, in the
following
my $str = 'moo \foo.* zoo';
my $a = ' \foo.*';
my $b = ' $';
$str =~ s/$a/$b/g;
I would like the value in $str to end up being 'moo $ zoo' while
allowing me to avoid having to escape in all the regex control
characters in the arguments to s///. Is there some qualifier I can use
to turn off regular expression interpretation in the arguments to s///
or some other way I can easily accomplish this without coding a new
subtroutine which takes the three arguments $str, $a, and $b and does
what I want?
Thanks, Dave