v2.22 release
[perl/plp/.git] / plp.cgi
diff --git a/plp.cgi b/plp.cgi
index 3bf77f9882d17b093afc6e4943ab31745105494a..4c6e41ef9eea938095e3b1bea4a9b6be95e4d6fd 100755 (executable)
--- a/plp.cgi
+++ b/plp.cgi
@@ -2,9 +2,12 @@
 use strict;
 use vars qw($VERSION %INTERNAL %get %post %fields %header %cookie %BLOCK $DEBUG $output);
 
-$VERSION = '2.21';
+$VERSION = '2.22';
 $DEBUG = 1;
 
+# We put most everything in %INTERNAL, just so the user won't screw it.
+# We could also have used packages, but let's keep it simple.
+
 $INTERNAL{file} = $ENV{PATH_TRANSLATED};
 unless (-e $INTERNAL{file}){
     $ENV{REDIRECT_STATUS} = '404';
@@ -26,8 +29,8 @@ use plp;
 $INTERNAL{qq} = "\10"; #^P
 $INTERNAL{q}  = "\17"; #^Q
 
-$header{'content-type'} = 'text/html';
-$header{status} = '200 OK';
+$header{'Content-Type'} = 'text/html';
+$header{Status} = '200 OK';
 
 $INTERNAL{code} = ReadFile($INTERNAL{file});
 
@@ -49,6 +52,8 @@ $INTERNAL{code} =~ s(\\\\\r?\n)()g;
 $INTERNAL{code} =~ s(<\[([^>]*?):(.*?)\]>)($BLOCK{"${1}-1"}$2$BLOCK{"${1}-2"})g;
 $INTERNAL{code} =~ s(<\[(?!/)(.*?)\]>)($BLOCK{"${1}-1"})g;
 $INTERNAL{code} =~ s(<\[/(.*?)\]>)($BLOCK{"${1}-2"})g;
+
+
 $INTERNAL{code} =~ s(<{[ \08\09]*)($INTERNAL{q};print qq$INTERNAL{qq})g;
 $INTERNAL{code} =~ s([ \08\09]*}>)($INTERNAL{qq};print q$INTERNAL{q})g;
 $INTERNAL{code} = "print q$INTERNAL{q}$INTERNAL{code}$INTERNAL{q};";
@@ -68,10 +73,21 @@ while ($INTERNAL{code} =~ s/<_(.*?)_>//s){
     }
 }
 
-for (keys %header){
-    print "$_: $header{$_}\n";
+print "\n\n" if $DEBUG == 2;
+
+{
+    my %HEADER;
+    for (sort keys %header){ # Sort, so lowercase and underscores come first)
+       my $copy = $_;
+       tr/_/-/;
+       s/\b(\w)(\w*)/\U$1\E\L$2\E/g;
+       $HEADER{$_} = $header{$copy};
+    }
+    for (keys %HEADER){
+        print "$_: $HEADER{$_}\n";
+    }
+    print "\n";
 }
-print "\n";
 
 {
     no strict;