Hi,
I'm having a problem where somehow a regexp does not work and the
program results in an error when the regexp is called using a variable.
Here is my code.
1 $filename = 'This is a directory\file\sub.txt';
2 $regex = '\\(\w+\.\w+)$';
3 if ($filename =~ /$regex/)
4 {print $1;} else
5 {print "nothing\n";}
The following error appears when I run the above.
"Unmatched ) before HERE mark in regex m/\(\w+\.\w+) << HERE $/ at
regexp.pl line 3."
However if I "copy/paste" the actual regexp from line 2 into line 3 and
not use the variable, the program works fine.
Why is that? I am using variables for regexp's in other programs I wrote
and they work fine. This one I'm not sure why its not working.
Any feedback will be appreciated greatly.
Thank you,
Ahmer
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>