generalize reading post input
[perl/plp/.git] / PLP / CGI.pm
index 9b72355c55eafd1050d20a7ae4fab305a2814fbe..56ca4db72eece75fcd434f6ed04211545ee4bc4d 100644 (file)
@@ -9,6 +9,7 @@ use PLP;
 # CGI initializer: opens SCRIPT_FILENAME
 sub init {
        $PLP::print = 'print';
+       $PLP::read = \&read;
 
        if (defined $ENV{PATH_TRANSLATED}) {
                # SCRIPT_* points to handler script (Apache CGI)
@@ -57,6 +58,12 @@ sub init {
        $PLP::code = PLP::source($file, 0, undef, $ENV{PLP_FILENAME});
 }
 
+sub read ($) {
+       my ($bytes) = @_;
+       read *STDIN, my $data, $bytes;
+       return $data;
+}
+
 # This is run by the CGI script. (#!perl \n use PLP::CGI; PLP::CGI::everything;)
 sub everything {
        PLP::clean();