Hello all,
I have the following small perl script:
#!\usr\bin\perl
my $thing;
open(DATA, "C:\\data.txt") || die "couldn't open data!";
while(<DATA>)
{
$thing = $_;
}
close(DATA);
open(STUFF, "C:\\stuff.txt") || die "couldn't open stuff!";
while(<STUFF>)
{
$all_stuff = $all_stuff . $_;
}
close(STUFF);
if( $all_stuff =~ m/$thing/ )
{
print "ok, $thing found \n";
}
else
{
print "oops, $thing not found \n";
}
My problem is that the file data.txt has only one line with one string which
has the '$' in it, like this one "Hi$Lia" , and when it goes and does the
pattern matching, it says that the
"Hi$Lia" string was not found in the $all_stuff variable, which is not true
since this variable has this string: "what a nice day. Hi$Liahow are you"
I guess the problem is with the '$', I tried escaping it but that didn't
work either.
How can I make this pattern matching above to work?
I have included my two sample files in the case that somebody would like to
try it...
Thank you for your help!
-Lia- <<testing.pl>> <<data.txt>> <<stuff.txt>>
testing.pl
Hi$Lia
what a wonderful day Hi$Liahow are you