>>>>> "KH" == Kee Hinckley <[EMAIL PROTECTED]> writes:
KH> First, I have a solution. But it's ugly as sin, so I was curious if
KH> there was a better one.
first off there is a related FAQ:
=head2 How can I expand variables in text strings?
KH> The solution is:
KH> $a =~ s/$b/eval("\"$c\"")/e;
that is ugly. :)
did you know you can do multiple levels of /e on s///? and i hate seeing
backwhacks in front of quotes. that usually means you should pick a
better delimeter. so this is a cleaned up version:
$a =~ s/$b/qq{"$c"}/ee;
the logic is exactly the same. you have to eval twice, first to get the
rid of the outer qq{} and the second to actually eval the string and
interpolate the $1.
another way to do this is to put the "" inside the original replacement
string:
$c = '"middle letter was $1!"';
$a =~ s/$b/$c/ee;
but you still need the double eval.
uri
--
Uri Guttman --------- [EMAIL PROTECTED] ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com