"McCollum, Frank" wrote:

> I am not getting the Find Function.  (FILE::FIND).  I have found all of
> these great examples on the web describing how to use the find function
> under the following two conditions...
>
> 1)  You know the exact File Name you are looking for, or you just want a
> list of every file in a directory
> 2)  You only want to print out some data in the &wanted routine.
>
> Does any one have some examples that would help me to do this:
> 1) Search a directory for a partial filename (i.e. "Inven" would return all
> files similar to "Inventory.pdf", etc.)

   use strict;
   use File::Find;
   find (\&match_pattern, $yourdirname);
   sub match_pattern {
        print "$File::Find::name\n" if (m/inven/); # The filename is stored in $_ by 
find
    }

     This should print all filenames that contain "inven" in them.
      Note : Matching is done only on the filename not on the entire path.
        i.e. /home/yourhome/inventory.pdf will match but
              /home/yourhome/inventory/test.txt will not

      If you want to do the matching over the entire path change the if to
       if ($File::Fine::name =~ m/inven/) #$File::Find::name contains the complete 
pathname to the file

       Read through perldoc File::Find to know about the different variables used by 
it.

>
> 2) Return the entire list of paths/filenames that match so I can fool around
> with the files some more.
>
> Thanks.
>
> Frank McCollum
> Bank Of America Securities, LLC
> [EMAIL PROTECTED]
> (704) 388-8894
>
> --
> 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