jcubic jcubic - 4 years ago 213
Perl Question

Read cgi raw post data without CGI module in perl

On my server I don't have CGI installed is it possible to get Raw Post Data without that module? I've try to check the source code for CGI.pm but didn't found anythig.

Answer Source

You can extract POST data by reading from STDIN. (Viewing raw POST data)



use strict;
use warnings;

my $buffer = '';
print "Content-type: text/plain\n\n";
print 'Post data is (' . length($buffer) . " chars):\n";
if( ! length($buffer) ) { $buffer = '[No POST data received]'; }
print $buffer;


<form method="post" action="">
<table cellpadding="3">
<td><input type="text" name="name" style="width:200px;"></td>
<td><input type="text" name="email" style="width:200px;"></td>
<td valign="top">Message:</td>
<td><textarea name="message" style="width:200px; height:75px;"></textarea></td>
<td> </td>
<td><input type="submit" style="width:200px;"></td>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download