in reply to Re: Re: string occurences
in thread string occurences

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Re: Re: Re: string occurences
by srawls (Friar) on Jun 12, 2001 at 21:34 UTC
    The problem is that the program will then increment that default hash value of 1.

    I don't see how that is a problem. Right now, this code:

    $counts{$url}=0 if !defined $counts{$url}; $counts{$url}++;
    Makes a new hash instance 0, than increments it; also incrementing each repeated instance. If you just take out that first line, the results are the same.

    On a side note, exists probably would have been better, instead of defined. But mabey that's just me : )

    The 15 year old, freshman programmer,
    Stephen Rawls

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Re: Re: Re: string occurences
by tigervamp (Friar) on Jun 13, 2001 at 03:09 UTC
    If the hash value is undefined, then is incremented, the new value will be 1, which means the url has appeared once so far, which is corect. There is no need to explicitly set each first-time occurence to 0, the counts will be the same either way, and MeowChow is correct.

    tigervamp