undefined warnings during Fields parsing
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 30 May 2008 17:37:09 +0000 (17:37 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 31 May 2008 20:00:07 +0000 (20:00 +0000)
Accessing undefined values pollutes error logs since
d9f3acb221a71e094318c7b5d3809aa81dbb5bb3 (use warnings in all modules).

lib/PLP/Fields.pm

index 212dec5c8e7486935cefd448bd48158458155299..52040e3f3455c082ff63c379a5d4d7235c907b37 100644 (file)
@@ -12,7 +12,7 @@ sub doit {
        # %get
        
        my $get = \%PLP::Script::get;
-       if (length $ENV{QUERY_STRING}){
+       if (defined $ENV{QUERY_STRING} and length $ENV{QUERY_STRING}){
                for (split /[&;]/, $ENV{QUERY_STRING}) {
                        my @keyval = split /=/, $_, 2;
                        PLP::Functions::DecodeURI(@keyval);
@@ -25,13 +25,10 @@ sub doit {
 
        tie %PLP::Script::post, 'PLP::Tie::Delay', 'PLP::Script::post', sub {
                my %post;
-               my $post;
-               
-               return \%post if $ENV{CONTENT_TYPE} !~
-                       m!^(?:application/x-www-form-urlencoded|$)!;
-               
-               $post = $PLP::read->($ENV{CONTENT_LENGTH}) if $ENV{CONTENT_LENGTH};
+               return \%post unless $ENV{CONTENT_TYPE} and $ENV{CONTENT_LENGTH} and
+                       $ENV{CONTENT_TYPE} =~ m!^(?:application/x-www-form-urlencoded|$)!;
                
+               my $post = $PLP::read->($ENV{CONTENT_LENGTH});
                return \%post unless defined $post and length $post;
                
                for (split /&/, $post) {