Cgiclient.Pl
From Pickwiki
Jump to navigationJump to searchSourceCode>>PerlSource
A perl client to take form fields and transfer them over to a server equipped to deal with them...
sunset /usr/local/apache/share/cgi-bin> cat cgiclient.pl
#!/usr/local/bin/perl
use CGI qw(:standard);
use IO::Socket;
$|=1;
print header();
$server = IO::Socket::INET->new("sunset:1999") or die "cgiclient.pl: $@\n";
$acc=param("account");
if ($acc eq "") {
print $client "<H1>Internal cgi error - must specify an account!</H1>\n";
return 0;
}
print $server $acc,"\n";
foreach $key (param()) {
# This join is a little obscure - if the field being returned is
# single valued it does nothing. only for select lists with multiple
# items does it produce a dynamic array
$value = join($fld_delim, param($key));
# Likewise, this next line usually does nothing, except when a multi-line
# text box is being retrieved. it too produces a dynamic array
$value =~ s/\r\n/$fld_delim/og;
# Send the data thru the named pipe to CGI.MASTER
print $server "$key=",$value,"\n";
}
shutdown($server,1);
print <$server>;
print end_html;