mhonarc-users

Re: Faster &get_last_msg_num (Was: Re: Newbie Q? - Message Jumping)

1997-01-14 17:25:47
I had a look at get_last_msg_num().  
 - any special reason why last msg number is not stored in .mhonarc.db?

It is to avoid clobbering msg files that someone may not want clobbered.

 - the routine seam to be a bit complicated, therefore ...  

I agree.

I've hacked together:

sub new_get_last_msg_num {
        opendir(DIR, $'OUTDIR) || &error("ERROR: Unable to open $'OUTDIR");
        local ($max) = -1;
        grep { /msg0*(\d+).html/; $max=$1 if $1 > $max; } readdir(DIR);
        close(DIR);
        $max;
}

The above is not legal perl 4.  See if the following is comparable
in speed performance:

sub get_last_msg_num {
    opendir(DIR, $'OUTDIR) || &error("ERROR: Unable to open $'OUTDIR");
    local($max) = -1;
    foreach (readdir(DIR)) {
        if (/msg0*(\d+).htm/) {
            $max = $1  if $1 > $max;
        }
    }
    close(DIR);
    $max;
}

        --ewh

<Prev in Thread] Current Thread [Next in Thread>