John W. Krahn told me on 02/11/2008 03:47 PM:
> Michael Barnes wrote:
>> I thought about using lstat to get the size of a file for file
>> comparisons.  I see that lstat always returns a list of thirteen values.
>>  The references I find appear to require assignment of those 13 values
>> to variables, even though I only want to use one.
>>
>> Do I really have to put
>>
>> ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
>>      $atime,$mtime,$ctime,$blksize,$blocks)
>>            = lstat($filename);
>>
>> Just to get the $size variable populated with the file size?
>>
>> My ultimate goal is to check the size of huge files copied to a folder.
>>  Once I get the $size to come back the same three times in a row,
>> indicating the file is all there, then I can move on with playing with
>> the file.
> 
> You could use the -s file test operator:
> 
> my $size = -s $filename;
> 
> 
> But that uses stat() instead of lstat().  If you really need lstat()
> then you could do it like this:
> 
> lstat $filename;
> my $size = -s _;
> 
> 
> 
> John
Such a wonderful wild variety of answers.  Thank you all so much.  It
matters not to me whether I use stat or lstat.

I have a folder being used in a dropbox environment.  I have a perl
script which examines that folder for the presence of a file, then takes
appropriate action on it, moving it to where it needs to be, removing it
from the dropbox folder.

My problem occurs when a user places a large (>300MB) file in the
dropbox folder.  As the script processes the file, it may not be all
there yet and as the script loops back around, it sees the file still
there and attempts to process it again while it is still being processed
by the first iteration.  My desire was to get the file size, wait, then
get the file size again and compare.  The thought being that if the file
returned the same size three times in a row, it could be assumed that
the file had completely copied into the dropbox folder and could now be
processed.

I'm just trying to keep this as basic, yet functional as possible.

Thanks for the various inputs.  Keep them coming.  This is very educational.

Michael


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to