Use quotemeta on $searchstring like this:

$searchstring = quotemeta $searchstring;
$LongString =~ s/$searchstring//gi;

-Kevin

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jose
Guevarra
Sent: Monday, February 24, 2003 1:46 PM
To: [EMAIL PROTECTED]
Subject: strict substitution in s/$var//


Hi,


I was trying to substitute a long string w/ '.','*',or other special
characters.

it seems that when I place this string in the subsitution operator it treats
it as an expression as opposed to a string.

so it doesn't pick up '.' or '*'.  I'm not using the 'treat as expression'
modifier either

im doing this

  $LongString =~ s/$searchstring//gi;

basically delete the $searchstring from the $LongString.

when I print out everything before during the operation I see that the exact
$searchstring is inside of the $Longstring but it is not replaced, when I
hard code the string it gets replaced.  How can I tell perl to use
$searchstring as the string to search but use a strict substitution like
'some string. here*' as opposed to "some string. here*"  where I
metacharacters are needed within the quotes?

thanx

jose

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to