fix delete %header
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 2 Jun 2008 06:56:40 +0000 (06:56 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 2 Jun 2008 06:56:40 +0000 (06:56 +0000)
Header value wasn't deleted case-insensitively.  Because the alias was
still removed correctly, it usually worked, but as of recently producing
warnings in sendheaders().

Also, delete returned the original key (not documented anywhere).
Change this to always return the deleted value, matching the behaviour
of normal hashes and user expectation.

Changes
lib/PLP/Tie/Headers.pm

diff --git a/Changes b/Changes
index 346aa4104bf9d3d27b42b389442e4f9c26627d2c..5c8b1d7ece6996fa2d6867be56febfefd142114c 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,4 @@
+- Fix delete %header
 - Fix breakage with old versions of Exporter
 - Tests emulating actual PLP usage
 
index ea2f172e1ae90ddb6dfa77981ddd1f37bc31ce2f..f0db9685db327b70ddbdf2ef9af4642a4a442277 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 use Carp;
 
-our $VERSION = '1.00';
+our $VERSION = '1.01';
 
 =head1 PLP::Tie::Headers
 
@@ -64,8 +64,8 @@ sub STORE {
 sub DELETE {
        my ($self, $key) = @_;
        $key =~ tr/_/-/;
-       delete $self->[0]->{$key};
-       return delete $self->[1]->{lc $key};
+       defined ($key = delete $self->[1]->{lc $key}) or return;
+       return delete $self->[0]->{$key};
 }
 
 sub CLEAR {