To: Jerry Yu... Re: [ale] 2 Perl questions ?

Courtney Thomas ccthomas at joimail.com
Wed Dec 15 19:16:34 EST 2004


Sriad,

I only want the 'picking' to simply be.... to merely add the file's 
sizes until >650MB, then don't add the one that puts the total >650MB 
and the 'moved-to' dir then contains that set the <=650MB, since each is 
moved to the new 'container' dir, and the program stops.

Hope that clarifies my simple objective,
Courtney


Aditya Srinivasan wrote:

> The other aspect of doing it on your own is :
> 
> The algorithm to separate files into groups <=650 sounds non trivial.
> 
> 1.List files and sizes
> 2.Sort
> 3.Pick appropriate combinations from the list (The hard part ??)
> 
> Is anyone aware of an algorithm which analyzes this sort of problem and 
> solves it ?
> Sounds like :
> 
> Given a set of n objects of different values, separate them into K
> groups such that sum of the objects of that group are less than M. 
> Optimize to minimize K
>  
> 
> Thanks,
> sriad
> 
> 
> On Wed, 15 Dec 2004, Courtney Thomas wrote:
> 
> 
>>Thanks Jerry.
>>
>>Know where I can lay hands on such an open-source program   :-)
>>
>>Cordially,
>>Courtney
>>
>>
>>Yu, Jerry wrote:
>>
>>
>>>2. you need to program it into a function/sub taking a direntry as its
>>>parameter, inside which you call itself recursively when a item is a
>>>directory
>>>1. initializing the same way you would do elsewhere in the program, "my
>>>$var1 = 1;" before use. 
>>>0. I believe there are open-source programs available to do what you try to
>>>do, unless you want to write it for fun.
>>>
>>>
>>># -----Original Message-----
>>># From: ale-bounces at ale.org [mailto:ale-bounces at ale.org]On Behalf Of
>>># Courtney Thomas
>>># Sent: Wednesday, December 15, 2004 10:28 AM
>>># To: ale at ale.org
>>># Subject: [ale] 2 Perl questions ?
>>># 
>>># 
>>># Purpose:
>>># 
>>># 	write a small program that will process all files in a 	
>>># 		designated dir, which 
>>># contains files and dirs, by examining each 	file entry and 
>>># sums it to a 
>>># total, which is less than some 			
>>># arbitrarily entered size, [in this case 
>>># <=650MB since the purpose 	is to aggregate chunks of the 
>>># original dir into 
>>># separate dirs <=650MB for burning to a CD], and if the total <=650MB, 
>>># then, move that entry into the new "burn" dir, and continue until a 
>>># total <=650MB is reached, then stop.
>>># 
>>># In this way I can take an arbitrary size dir and allocate it to any 
>>># number of burn dirs of <=650MB, then burn 'em.
>>># 
>>># --------------------------------------------------------------
>>># -----------
>>># 2 Problems:
>>># 
>>># 1-The compiler is complaining about uninitialed variables within a 
>>># "while" loop. How do I properly initialize numeric variables 
>>># within the 
>>># loop ?
>>># 
>>># 2-I also need to traverse a dir that itself contains dirs, processing 
>>># each file and dir. How do I traverse such a dir such 
>>># that....when a dir 
>>># is encountered it is entered and all the files in it are then 
>>># processed, 
>>># and if necessary drills down through other dirs [howto control depth 
>>># ?]...before returning to the original dir that contained 
>>># files and dirs ?
>>># 
>>># --------------------------------------------------------------
>>># ------------
>>># 
>>># 
>>># Appreciatively,
>>># Courtney
>>># 
>>># 
>>># 
>>># -- 
>>># s/v Mutiny
>>># Rhodes Bounty II
>>># lying Oriental, NC
>>># WDB5619
>>># 
>>># _______________________________________________
>>># Ale mailing list
>>># Ale at ale.org
>>># http://www.ale.org/mailman/listinfo/ale
>>># 
>>>
>>>This email and any attached files herein contain information that is intended only for the use of the individual or entity to whom it is addressed and may contain information that is legally privileged, confidential or otherwise exempt from disclosure under applicable laws. If the reader of this message is not the recipient, any disclosure, dissemination, distribution, copying or other use or retention of this communication or its substance is prohibited.
>>>
>>>
>>>_______________________________________________
>>>Ale mailing list
>>>Ale at ale.org
>>>http://www.ale.org/mailman/listinfo/ale
>>>
>>>
>>>
>>
>>
> 


-- 
s/v Mutiny
Rhodes Bounty II
lying Oriental, NC
WDB5619



More information about the Ale mailing list