Hi,
Howdy.
I want to match a pattern and replace with another string.Since the "?"
is also one of the character present in the string.
I am not able to do it.
I bet we can fix that.
Please help to how to make "?" acceptable in the string used for pattern
matching.
My problem is:
Here in the script,how to make the Perl to accept "?" symbol in the string
for pattern matching.
my $pattern="<a href=\"yahoo.com/getfile.php?id=1894\">Dennis"; my $replace="<script>\ndocument.write(\"<a href = \"url+\"/getfile.php?id=1894\">Dennis"; open(IN, "<$filetoopen") || die "cannot open file\n"; open(OUT, ">$test") || die "cannot open file\n"; while (<IN>){ if (/$pattern/){ s/$pattern/$replace/g; }
First, there is no reason to do two pattern matches here. Drop the if (/$pattern/) { }, since it does nothing but waste time.
The other match is easy to fix:
s/\Q$patterrn\E/$replace/g;
Hope that helps.
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>