Cache::Memcached - pos() weirdness

Brad Fitzpatrick brad@danga.com
Thu, 20 May 2004 13:31:48 -0700 (PDT)


Bizarre.  What version of Perl?


On Thu, 20 May 2004, Dave Evans wrote:

> A few times I've come across some rather odd behaviour in the Perl binding,
> Cache::Memcached.  Typically the following warning is emitted:
>
>   Use of uninitialized value in subtraction (-) at Cache/Memcached.pm line 494.
>
> which is this line:
>
>   my $copy = $len-$p > $state{$sock} ? $state{$sock} : $len-$p;
>
> The cause seems to be that pos() has returned "undef" - this in spite of the
> fact that the last m//g match was successful (just a few lines further up).
> "perldoc -f pos" tells us that undef() is returned if and only if the match
> failed.  So, I'm at a loss to explain what's going on.  I'd love to hear an
> explanation, if anyone has one.
>
> What I /can/ be sure about is that when it does happen, it causes problems,
> because effectively the whole response "VALUE key n n ..." is interpreted as the
> value from the cache.  Ooops.
>
> Because I have no idea why pos() is playing up, I modifed the code not to rely
> on pos() any more, which makes this problem go away (for me).  Patch attached.
>
> Thanks,
>
> --
> Dave Evans
>
> PGP key: http://rudolf.org.uk/pgpkey
>
>