http://qs1969.pair.com?node_id=1154491

swampyankee has asked for the wisdom of the Perl Monks concerning the following question:

I did a quick search, but didn't quite find anything that was sufficiently close to be an answer

I'm trying to use File::Find to find image files, so I can randomly change my wallpaper. I know; it's a silly task ⌣. My problem is that I have a bunch of image files on a flash drive, and File::Find won't follow a symbolic link to the contents of the flash drive. I suspect it's because File::Find, even when $File::Find::follow is set won't recurse into a different file system.

I'm using Fedora 21, Perl v5.18.4, File::Find version 1.23.

sub image_search { my $name = $File::Find::name; my $dir = $File::Find::dir; my @globbed; my @temp; my $images = '(png$)|(jpg$)|(gif$)|(jpeg$)'; if (-l $name) { print "processing link named $name\n"; @globbed = glob("$name/*"); } else { print "processing directory named $dir\n"; @globbed = glob("$dir/*"); } if (@globbed) { @globbed = grep {m/$images/i} @globbed; $image_list{$dir} = [@globbed]; } } ## end sub image_search
Sorry for the a) less-than-optimal code design and b) absence of comments.

Information about American English usage here and here. Floating point issues? Please read this before posting. — emc