Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

richardc (1662)

  (email not shown publicly)

Journal of richardc (1662)

Saturday June 14, 2003
10:21 AM

evolving - Saturday 10th May, 2003

[ #12827 ]

Had correspondence from a user of File::Find::Rule who wanted to dothe slightly fun "all directories which contain files called *.jpg". Went a bit small-tools crazy as this is what I came up with:

use strict;
use File::Find::Rule;
use File::Basename qw(dirname);

my @dirs = keys %{ { map {
     dirname( $_ ) => 1
} find( file => name => '*.jpg', in  => '.' ) } };

Tell a lie. The code I sent was much less golfier, since even with small tool mania I felt compelled to be clear, but I still enjoyed combining two modules to get the desired effect rather than needing any more code.