- From: security.department@xxxxxxxx (Hans Meier)
- Date: Mon, 13 Feb 2006 17:31:01 +0100
Bowen, Bruce am Sonntag, 12. Februar 2006 22.31:
I have a text string = "^0176 ^0176"
I have set $a = "^0176 ^0176";
I have set $b = "^0176 ";
I'm using text =~ s/$a/$b/g;
And the text string doesn't change. I expected it to come out as "^0176 "
after the substitution. What is wrong with my logic?
Not shure if it's clear now after Tom's and Michael's posts.
Compared to the '\^'-solution, Tom's advice is generic (meaning that you have
not to know which meta characters - there are more than the caret - are in $a
and dont have to handle them explicitly). It's also more readable.
So it's the preferred way to do it.
explains all in full detail.
use strict; # don't forget
use warnings; # those two
my $a='^0176 ^0176'; # note the
my $b='^0176 '; # single quotes
my $text='some text ^0176 ^0176 here ^0176 ^0176 and there';
print "a) $temp\n";
print "b) $temp\n";
Hope $text does not contain votes ;-)
- From: Bruce Bowen