in reply to Optical drive contents listing problem

readdir is low-level, avoid it , use Path::Tiny
use Path::Tiny qw/ path /; my @files = path( 'anypath' )->children( qr/^[a-z].+\.txt$/ );
fion

Replies are listed 'Best First'.
Re^2: Optical drive contents listing problem
by karlgoethebier (Abbot) on Feb 22, 2015 at 14:14 UTC
    "readdir is low-level, avoid it, use Path::Tiny"

    After having another Déjà vu because you post this more often i decided to stop being ignorant and read the manual of Path::Tiny. This is cool stuff.

    And i think the links to similar modules the author provides, are also very, very useful.

    Let me cite from the docs of Path::Iterator::Rule, if you aren't the author ;-)

    use Path::Iterator::Rule; my $rule = Path::Iterator::Rule->new; # match anything $rule->file->size(">10k"); # add/chain rules # iterator interface my $next = $rule->iter( @dirs ); while ( defined( my $file = $next->() ) ) { ... } # list interface for my $file ( $rule->all( @dirs ) ) { ... }

    And IMHO The Real Thing is:

    $rule->contents_match(qr/BEGIN .* END/xs); $rule->line_match(qr/^new/i, qr/^Addition/);

    Thank you very much for pointing me to this stuff and best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»