#!/usr/bin/perl # # Find::File testcase # # This highlights that in perl 5.7 Find::File traverses directories # in the reverse order to that either from a unsorted directory listing # or a user sorted list. # # It also shows that non-directories names are process before any directories # regardless of the order given by the user. No option about this is provided # to users of the module. # # See "file_traversal_notes" for more information # use strict; use File::Find; my %find_opts = ( preprocess => \&sort_dir, # sort the contents of a directory wanted => \&do_files, # process each item in directory ); find(\%find_opts, "."); sub sort_dir { print "Traverse: $File::Find::dir (", scalar @_, ")\n"; return ( sort @_ ); # Sort filenames. #return ( @_ ); # Don't Sort filenames. } sub do_files { print "\t$_\n"; #print "\t$File::Find::name\n"; }