-----Original Message-----
From: Brian Volk
Sent: Thursday, May 19, 2005 11:44 AM
To: Beginners (E-mail)
Subject: Matching a $string w/ $string plus any extension
Hi All,
I'm trying to print a file name(s) if it matches $query... which is the
basename. I think I can do this w/ a regex? This is the line I'm having
trouble with.
print "$_\n" if (/$query.\w*/ eq $_);
If I'm understanding Learning Perl correctly... the dot ( . ) is a wildcard
and will match any character including the dot, which is what I'm trying to
do. Then match any other character(s) ... so I used the \w+ Can someone
pls explain what I'm doing wrong.
Thanks!!
__BEGIN__
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
my $query = "30700";
# my $string = File::Find::Name;
find(\&wanted, 'w:/html/msds');
sub wanted {
return if ($_ =~ /^\./);
print "$_\n" if (/$query.\w+/ eq $_);
}
__END__
Sorry to re-post to my own message... but I figured it out... for now
anyway.. :~)
find(\&wanted, 'w:/html/msds');
sub wanted {
return if ($_ =~ /^\./);
print "$File::Find::name\n" if ( m/$query/ );