in reply to Re: simple regex match question
in thread simple regex match question

That doesn't seem to work...well, it works, but returns no files. Here is my test code:
#!/usr/bin/perl use warnings; use Cwd; use File::Find; my $file_pattern ="*.txt"; find(\&d, cwd); sub d { my $file = $File::Find::name; return unless -f $file; return unless $file =~ /\Q$file_pattern\E$/; print "text file:$file\n"; }

Replies are listed 'Best First'.
Re^3: simple regex match question
by davido (Cardinal) on Nov 13, 2006 at 06:11 UTC

    I didn't know what you were doing, but now I get it.

    The * character is not a wildcard in Perl. That's a shell wildcard. You cannot expect a regular expression to recognize shell-style wildcards; they're different "languages".


    Dave