-if ($ENV{QUERY_STRING} ne ''){
- for (split /&/, $ENV{QUERY_STRING}) {
- split /=/;
- for (@_) {
- $_ = DecodeURI($_);
+#!/usr/bin/perl
+# shebang only for color coding, just ignore it m'kay?
+use strict;
+use vars qw(%get %post %fields %cookie %INTERNAL);
+
+$INTERNAL{getsub} = sub {
+ my %get;
+ if ($ENV{QUERY_STRING} ne ''){
+ for (split /&/, $ENV{QUERY_STRING}) {
+ my @keyval = split /=/;
+ DecodeURI(@keyval);
+ $get{$keyval[0]} = $keyval[1];
}
- $get{$_[0]} = $_[1];
}
-}
+ return \%get;
+};
-
-$INTERNAL{post} = <STDIN>;
-if ($INTERNAL{post} ne ''){
- for (split /&/, $INTERNAL{post}) {
- split /=/;
- for (@_) {
- $_ = DecodeURI($_);
+$INTERNAL{postsub} = sub {
+ my %post;
+ $INTERNAL{post} = <STDIN>;
+ if (defined($INTERNAL{post}) && $INTERNAL{post} ne '' &&
+ ($ENV{CONTENT_TYPE} eq '' || $ENV{CONTENT_TYPE} eq 'application/x-www-form-urlencoded')){
+ for (split /&/, $INTERNAL{post}) {
+ my @keyval = split /=/;
+ DecodeURI(@keyval);
+ $post{$keyval[0]} = $keyval[1];
}
- $post{$_[0]} = $_[1];
}
-}
-%fields=(%get, %post);
+ return \%post;
+};
+
+$INTERNAL{fieldssub} = sub {
+ $get{PLPdummy}, $post{PLPdummy}; # Trigger creation
+ return {%get, %post}
+};
+
+tie %get, 'PLP::Delay', 'main::get', $INTERNAL{getsub};
+tie %post, 'PLP::Delay', 'main::post', $INTERNAL{postsub};
+tie %fields, 'PLP::Delay', 'main::fields', $INTERNAL{fieldssub};
+
+#%fields = (%get, %post);
-$INTERNAL{koek} = $ENV{HTTP_COOKIE};
-if ($INTERNAL{koek} ne ''){
- for (split /; ?/, $INTERNAL{koek}) {
- split /=/;
- #for (@_) {
- # $_ = DecodeURI($_);
- #}
- $cookie{$_[0]} ||= $_[1];
+if (defined($ENV{HTTP_COOKIE}) && $ENV{HTTP_COOKIE} ne ''){
+ for (split /; ?/, $ENV{HTTP_COOKIE}) {
+ my @keyval = split /=/;
+ $cookie{$keyval[0]} ||= $keyval[1];
}
}