Francesco Del Vecchio wrote: > suppose this: > ====================================== > $string 'I saw Roger and I said :roger? what the @*$!'; > > $var1 = "roger? what the @*$!"; > $var2 = "Hi roger...nice to meet you"; > > $string=~ s/$var1/$var2/; > ======================================= > > I'm having problems....due (i suppose) to the special chars in the $var1 > string the s/// don't match anything. > What can I do to? > > thanx > Francesco
Two things: First, it's better if you post to the list by NOT replying to someone else's post. When you do this, it references the previous post via the message-id, and appears threaded below a post with a completely different Subject line. If you are starting a completely new thread, don't reply .. just create a new e-mail to the list address. (the problem with the above is that if I "mark the thread as 'read'", your post gets ignored, and I never see it since it's buried below the other thread's subject.) On to your question. s{\Q$var1\E}{$var2} is usually what you want, except that may very well 'quote' out the $ in $var. I suspect what you really want is $var1 = qr{roger? what the @*$!}; ( perldoc -f qr ) (perldoc perlre) and (perldoc perlop) for more details. I'd also recommend you add use warnings; use strict; to the top of every script you write. This will catch a LOT of potential mess-ups that would be hard to find otherwise. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]