in reply to Problem with Tie::RegexpHash

Change lines 58 and 59 of Tie::RegexpHash as follows:

# while ( ($key ne $self->{KEYS}->[ $i ]) and # ($i < $self->{COUNT}) ) { while ( ($i < $self->{COUNT}) and ($key ne $self->{KEYS}->[ $i ]) ) {

and evaluates left to right. I think the original author meant to short-circuit, but somehow reversed the comparisons.

Replies are listed 'Best First'.
Re: Re: Problem with Tie::RegexpHash
by robartes (Priest) on Oct 10, 2002 at 18:27 UTC
    jsprat is absolutely right. The RegexpHash.pm code as is overruns the end of the array referenced in KEYS. The warning the POD talks about is a bit further down in the module in the add method. That warning is generated by the module itself, not by Perl as it was in this case.

    CU
    Robartes-