in reply to Re^2: Can I get help with Perl glob for filtering a directory
in thread Can I get help with Perl glob for filtering a directory
Grepping readdir seems pretty easy, aside from needing to opendir and check for errors, but the Path::Tiny ->children regex option is the easiest of all. Glob is easy if you want case-sensitive matches, which almost all Unix scripts would (the environment for which Perl was created). You also have the option of grepping glob, to save the opendir call:
my @files= grep /\/\Q$fileName\E$/i, <$dirName/*>;
but note that one important difference between glob and readdir is that glob will return the path portion as you specified it in the pattern.
|
|---|