Cache::Memcached - pos() weirdness
Brad Fitzpatrick
brad@danga.com
Mon, 19 Jul 2004 13:48:33 -0700 (PDT)
On Sun, 18 Jul 2004, Dave Evans wrote:
> Brad Fitzpatrick wrote:
> > This is still hanging around my inbox, but I feel dirty applying it
> > without knowing the real problem. (which I suspect is Perl's fault)
>
> Agreed on both counts.
>
> > Dave: can you test this one-liner instead:
> > From:> my $p = pos($buf{$sock});
> > To: > my $p = pos($buf{$sock}) || length($&);
> >
> > That way it shouldn't slow down or otherwise affect anything except on
> > broken taint systems.
>
> Actually if you don't mind I shan't bother trying that change, because
> it /would/ slow a lot of things down - see "$&" in "man perlvar":
> The use of this variable anywhere in a program imposes a considerable
> performance penalty on all regular expression matches.
Oh yeah. I tend to use $&, $`, and $' often enough that I just accept I
use them somewhere else in my program and take the speed penalty. I
didn't realize memcached.pm didn't already use them, in which case I'd
like to keep it that way and not penalize others using this module.
> My current favourite patch for the problem is here:
> http://rudolf.org.uk/utils/Cache-Memcached-1.13-taint.patch
Crazy! I didn't know about @+. I'm wondering why you're killing this
line, though:
- pos($buf{$sock}) = 0;
Do we just never care about pos() anymore? I'll have to go reread the
code with more context.
I'll more than likely commit this patch, if I can't see any problems.
(with a comment saying it avoids problems under taint mode)
- Brad