
davorg
Thaumaturge
/ Moderator
Jun 23, 2006, 2:57 AM
Post #2 of 2
(371 views)
|
|
Re: [abhisri] filename matching
[In reply to]
|
Can't Post
|
|
I can see two problems here. One specific and one more general. The specific problem is with your syntax. Your filename check looks like this:
if( $flname = ~ /^$filename/ ) You've taken the =~ operator and split it into two. Perl interprets that as the = operator followed by the ~ operator. That's not what you want at all. Incidently, if your match operator was working as you expected, it still wouldn't be going the right thing as your regex is checking for strings that start with $filename not strings that equal $filename. It's a subtle difference, but it might be important. Also for checking string equality, the equality operator (eq) is better than the match operator. The more general problem is that you're doing far too much work for yourself. You've basically reinvented the glob. Why not use that instead. -- Dave Cross, Perl Hacker, Trainer and Writer http://www.dave.org.uk/ Get more help at Perl Monks
|