[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Memory leak?



Strider,

In addition to Jon's comments, you may want to consider these
alterations to your code for efficiency. (Do as I say, not as I do ;-)

for $i (0 .. $#ARGV) {
    # open file dropped on droplet
    open (IN, "$ARGV[$i]") || die "couldn't open file in";
    
    while (<IN>) {

        # there's only one newline and this gets it
        # without the extra overhead of chomping an array
        # when you don't have to
        #
        chomp; 
        
        # Consider the form:
        # split /PATTERN/,EXPR,LIMIT 
        # that way, since you already have tabs
        # you don't have to work twice as hard
        #
        # id, date, online (secs), logons, bad discos, router[s]
        #
        ( $user, $date, $remainder ) = split( /\t/, $_, 3 ); 
        
        # if it's already defined, (and you don't want dupes)
        # you shouldn't need to define this more than once 
        # unless you're trying to get the last 
        # $data{ $user }{ $date } entry in the log
        #
        unless ( $data{ $user }{ $date } ) {
            $data{ $user }{ $date } = $remainder; # now %data
        }
    }
    close IN;
}

Regards,

Walter Hinton
red@dig-it.com

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch