Wow.. I thought about "eval"ing $replacement only, but this way.. It works great. Except it is a brain damage (for me) to understand why it works ;)
This trick with \$str in "eval" is really worth a record in Cookbook. The actual task which caused the issue is that parts of regexp are given be a user in GUI, but regexp itself is executed later in the program. So i needed a general way of handling $replacement like things. Thanks a lot, Artem A. Avetisyan. > > > Hi > > I try with qr//, but found nothing good, > but "eval" work well > > my $str = 'lazha'; > my $pattern = 'la(zh)(a)'; > my $replacement = '$1o"p$2'; > eval "\$str =~ s/$pattern/$replacement/;"; > print$str; > __END__ > zho"pa > ----- Original Message ----- > From: "Артем Аветисян" <[EMAIL PROTECTED]> > To: <perl-win32-users@listserv.ActiveState.com> > Sent: Tuesday, December 06, 2005 4:47 PM > Subject: Forced interpolation > > > > Hi, all. > > > > use strict; > > my $str = 'lazha'; > > my $pattern = 'la(zh)(a)'; > > my $replacement = '$1o"p$2'; > > > > $str =~ s/$pattern/$replacement/; > > print $str; > > __END__ > > > > I want > > > > zho"pa > > > > to be printed. So far it is obviously '$1o"p$2'. eval (as well as s///ee) > doesn't seem to be helpful. > > More generally, I want to know if there is a way to interpolate variables > in a single quoted string (or possibly change the quotation before?) at any > moment. > > > > Thanks, > > Artem A. Avetisyan. > > > > _______________________________________________ > > Perl-Win32-Users mailing list > > Perl-Win32-Users@listserv.ActiveState.com > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > > This message contains information that may be privileged or confidential and > is the property of the Capgemini Group. It is intended only for the person to > whom it is addressed. If you are not the intended recipient, you are not > authorized to read, print, retain, copy, disseminate, distribute, or use > this message or any part thereof. If you receive this message in error, > please notify the sender immediately and delete all copies of this message. > _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs