Hi, Joe,

On Mon, 8 Dec 2003 12:04:28 -0500, "Joseph Discenza"
<[EMAIL PROTECTED]> wrote:

> Peter Davis wrote, on Monday, December 08, 2003 11:04 AM
> :  I'm keeping my e-mail in MH format, which means each folder is a
> :  directory, and each message is in a separate file, and the filename
> is:  the message number.  Now I'm writing a Perl script to re-sort
> messages:  into different folders, so I need to find the highest
> number already in:  the folder, so I can add one to it and use that as
> the new filename.
> 
> Yours is the only process putting messages in the folder, so
> there's no race conditions? OK.

That's right.

> You've got a bunch of files in each directory, or you wouldn't
> be worried about efficiency, right?

Yes.  There are potentially thousands of files in each directory.

> Do you need to find the last for each folder over different
> invocations of the program, or is this a one-time sort? If it's
> one-time, put the highest number in a hash or array.

Well, I plan to cache the number during the run of the script, so that
if I move multiple messages to the same folder, I can just increment the
cache each time, without having to re-determine the highest message
number.

> Now, presuming it's different invocations, the simplest way is to
> put the highest number in a control file: open that up, read the
> number, and close. Then when you're done, open for writing, write
> the new highest number, and close.

Yes, that would work, though I'm wary of keeping persistent information
this way.  If I do something between invocations that changes the
message numbering (e.g., MH sortm), it will invalidate the control file.
If I can make it reasonably efficient, I can bear the cost of getting
these numbers once per mail fetch.

Thanks!

-pd


-- 
--------
                             Peter Davis
               Funny stuff at http://www.pfdstudio.com
                 The artwork formerly shown as prints
    List of resources for children's writers and illustrators at:
                  http://www.pfdstudio.com/cwrl.html

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to