in reply to How can I readdir and ! -d in one line
grep can take a BLOCK with multiple tests and/or you can just use and and chain multiple checks (recommended best practice is to use the BLOCK form rather than the EXPR form these days anyhoo). Or use something like File::Find::Rule rather than lower level primitives.
my @F = grep { /^\w/ and not -d "$myDir/$_" } readdir( I );
Edit: Path::Tiny is another possibility.
use Path::Tiny; my @files = grep !$_->is_dir, path( $myDir )->children( qr/^\w/ );
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I readdir and ! -d in one line
by misterperl (Friar) on Oct 27, 2020 at 17:22 UTC | |
by Fletch (Bishop) on Oct 27, 2020 at 17:46 UTC |