b888 has asked for the wisdom of the Perl Monks concerning the following question:
Gretting all.
I trued to use variables in s/// and met following problem: perl interpreter tries to use these variables' values as reg expessions. How can i ommit this?
In general algorythm looks like
my $line = "<a href=\"/{HOST}?action\">123</a>:</b><br>". "[img-smile \"58-41\" \":)\"]"; my $var1 = "<img src=\"1-2.gif\" alt=\"[---]\">"; (my $var2) = $line =~ /(\[img-smile [^]]+\])/; $line =~ s/$var2/$var1/; print $line;
And get Invalid [] range "8-4" in regex; marked by <-- HERE in m/[img-smile "58-4 <-- HERE 1..."
P.S. I can't use ' instead of " because of algorytm specific.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: using variables in regular expr replace
by Joost (Canon) on Dec 02, 2004 at 17:45 UTC | |
by Fletch (Bishop) on Dec 02, 2004 at 17:57 UTC | |
Re: using variables in regular expr replace
by Eimi Metamorphoumai (Deacon) on Dec 02, 2004 at 17:53 UTC | |
by b888 (Beadle) on Dec 02, 2004 at 18:05 UTC |
Back to
Seekers of Perl Wisdom