in reply to Re^2: Perl List files in directory
in thread Perl List files in directory
I'd suggest a small tweak to that:
@files = grep {-f "$dir/$_" && /\.xml$/i} readdir DIR;Because otherwise the regular expression would have matched a file named "fooxml.bar" as well. Also, this now matches the extension case-insensitively, just in case.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl List files in directory
by Anonymous Monk on Apr 24, 2014 at 14:22 UTC | |
by Corion (Patriarch) on Apr 24, 2014 at 14:31 UTC | |
by Anonymous Monk on Apr 24, 2014 at 14:33 UTC |