Bob Showalter                                                      
                                 
                    <Bob_Showalter@taylor        To:     
"'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>, 
                    white.com>                   [EMAIL PROTECTED]                    
                                 
                                                 cc:                                   
                                 
                    01/11/02 11:06 AM            Subject:     RE: Help with File::Find 
                                 
                                                                                       
                                 
                                                                                       
                                 







> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 11, 2002 11:58 AM
> To: [EMAIL PROTECTED]
> Subject: Help with File::Find
>
>
> Hi Everyone!
>
> I'm fairly new to Perl, and completely new to submitting to
> the list, so
> please be easy on me.  :-)
>
> The purpose of the code I wrote (listed below) is to go
> through the current
> directory and all of its subdirectories and report the
> filename, size and
> age of the x largest files, where x depends on the argument
> supplied on the
> command line and the number of files in the directory.  I'm
> sure there's an
> easier way to do this with a UNIX utility (or with Perl), but
> this program
> has been a good learning experience for me.
>
> The code below runs without any syntax errors, but File::Find
> (which I love
> and use frequently) or the -e file test doesn't give the
> results I expect.
> Specifically, my (explicit) checks show that the test in line
> 11 does not
> always evaluate to TRUE for values of $_ corresponding to
> legitimate (i.e.,
> existing and size > 0) files, which means I'm missing files
> that should be
> in my final output.  If I change line 11for debugging
> purposes to simply
>
> if ($_){
>
> all files (including the previously missed ones) are printed out (also
> along with the directories now) as expected, but for the
> files that would
> not have passed the (-e $_) test, the values assigned for
> filesize and age
> in line 12 are (tested to be) undefined.  If this is any
> help, the files
> that don't pass the (-e $_) of test of line 11 are (perhaps
> coincidentally)
> the biggest files (~55 GB)  in the directory.

I don't really have an answer, but conceptually, why would you need
a -e test at all? If the file doesn't exist, how would wanted() get
called for it?

Also, have you tried doing the -e on $File::Find::name instead of $_ ?
Perhaps there's some problem in changing directories.

Hi Bob,

Thanks for the response! Good question:  My original code - which produced
the same results - used the -f test because I don't want to include
directories in my final output.  I don't think the problem is with changing
directories, because within a given directory, some files will be listed
and others will be omitted.

Thanks!




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

Reply via email to