develooper Front page | perl.beginners | Postings from December 2011

Re: File Size Script Help - Working Version

Thread Previous | Thread Next
From:
Igor Dovgiy
Date:
December 30, 2011 03:58
Subject:
Re: File Size Script Help - Working Version
Message ID:
CADGQiHEa+qJ=Zk_uFmUSG_p61MZ=SnXCqA5y2fMz=WyOV_CzHA@mail.gmail.com
Hi John, yes, good point! Totally forgot this. ) Adding new files to a
directory as you browse it is just not right, of course. Possible, but not
right. )

I'd solve this by using hash with filenames as keys and collected 'result'
strings (with md5 and filesizes) as values, filled by File::Find target
routine.
After the whole directory is processed, this hash should be 'written out'
into the target directory.

Another way to do it is to collect all the filenames instead into a list
(with glob operator, for example), and process this list after.

BTW (to Jonathan), I wonder do you really need to store this kind of data
in different files? No offence... but I can hardly imagine how this data
will be used later unless gathered into some array or hash. )

-- iD

2011/12/30 John W. Krahn <jwkrahn@shaw.ca>

> Jonathan Harris wrote:
>
>>
>>>  Hi John
>>
>> Thanks for your 2 cents
>>
>> I hadn't considered that the module wouldn't be portable
>>
>
> That is not what I was implying.  I was saying that when you add new files
> to a directory that you are traversing you _may_ get irregular results.  It
> depends on how your operating system updates directory entries.
>
>


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About