use File::Find; find (\&tree, "/path"); sub tree { return unless -f $File::Find::name; my $filename = lc $_; return unless $filename=~ m/\.(jpg|gif)$/i; print "$File::Find::name\n"; }