uttsu.com >
receive.pl
use strict;
my %form;
main();
exit;
sub main {
get_form();
open(OUT, "> a") or die;
foreach (sort keys %form) {
print OUT "$_: $form{$_}\n";
}
close(OUT);
print "Content-type: text/html\n\nOK!\n";
}
sub get_form {
if ($ENV{REQUEST_METHOD} =~ /^post$/i) {
$_ = <STDIN>;
} else {
$_ = $ENV{'QUERY_STRING'};
}
@_ = split(/&/);
foreach (@_) {
my ($property, $value) = split(/=/);
$value =~ tr/+/ /;
$value =~ s/%([0-9a-fA-F][0-9a-fA-F])/pack("C",hex($1))/eg;
$form{$property} = $value;
}
}
Copyright (C) Takashi Utsunomiya. All Rights Reserved.
2002.11.20掲載