in reply to Re: Tk::Image delete method
in thread Tk::Image delete method

Thanks for the tip, Path::Tiny is a sweet module! I had switched to File::Find and see these are all equivalent:
use File::Spec::Functions; opendir (my $dh, $dir); @img = map { catfile($dir,$_) } grep /\.(jpe?g|gif|png|bmp)$/i, readdi +r $dh; closedir $dh; use Path::Tiny 'path'; @img = path( $dir )->children( qr/\.(jpe?g|gif|png|bmp)$/i ); use File::Find; find(sub { push @img, $File::Find::name if /\.(jpe?g|gif|png|bmp)$/i && $dir eq $File::Find::dir }, $dir);
I used File::Find because recursion is so easy, by removing the $dir constraint:
find(sub { push @img, $File::Find::name if /\.(jpe?g|gif|png|bmp)$/i }, $dir);
Does Path::Tiny support such recursion? I can't figure it out from the doc. Thanx again.

Replies are listed 'Best First'.
Re^3: Tk::Image delete method
by choroba (Cardinal) on Jan 04, 2020 at 00:15 UTC
    > Does Path::Tiny support such recursion?

    Of course it does. The visit method is the most similar to File::Find's way:

    my @img; path($dir)->visit(sub { push @img, $_->stringify if /\.(jpe?g|gif|png|bmp)$/i; }, {recurse => 1});
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re^3: Tk::Image delete method
by Anonymous Monk on Jan 01, 2020 at 13:08 UTC