Gary Hawkins wrote:

> >     Read through 'preprocess' subsection of the File::Find docs
> > (perldoc File::Find).
> >     This might be of help to you.
>
> I already read the fantastic manual and was hoping for something that conveys
> understanding.
>
>     "preprocess"
>        The value should be a code reference. This code reference is used to
>        preprocess a directory; it is called after readdir() but before the
>        loop that calls the wanted() function. It is called with a list of
>        strings and is expected to return a list of strings. The code can be
>        used to sort the strings alphabetically, numerically, or to filter
>        out directory entries based on their name alone.

    This is an example code

      #!/usr/local/bin/perl
      use strict;
      use File::Find;

      find ( {wanted => \&printFiles, preprocess => \&sortFiles}, $yourdirname);
      # The first argument to the find routine can be a hash reference. The keys being 
the various
      #  operations that can be performed on the file. The 'preprocess' if specified 
is a reference to
      #  a subroutine. To this subroutine will be passed a list of files in the 
directory currently scanned.
      #  You can play around with list (sort it lexically etc.)
      #  To notice the difference in output comment the previous find call and 
uncomment the next
      #  find call.

     #find (\&printFiles, 'dirs');
     sub sortFiles {
       sort (@_);
     }

     sub printFiles {
       print "$File::Find::name\n";
     }

      hth,
      Sudarsan

>
>
> /g
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to