undefined warnings while reading unknown headers
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 31 May 2008 20:35:54 +0000 (20:35 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 31 May 2008 21:23:25 +0000 (21:23 +0000)
Return undef for unaliased headers right away, instead of trying to find
$header{+undef}.  Result is the same (the '' header never exists at this
point), but without the warning.

lib/PLP/Tie/Headers.pm

index 8e023fb4fab45ce4cefb8ec8eee5dfac21b5e0ad..ea2f172e1ae90ddb6dfa77981ddd1f37bc31ce2f 100644 (file)
@@ -39,7 +39,8 @@ sub FETCH {
                $self->[2] = 0;
        }
        $key =~ tr/_/-/;
-       return $self->[0]->{ $self->[1]->{lc $key} };
+       defined ($key = $self->[1]->{lc $key}) or return;
+       return $self->[0]->{$key};
 }
 
 sub STORE {