[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] STDIN problem




why not use CGI.pm then you can just access any passed parameters like this

#! perl -w

use strict;
use CGI;

my $cgi = new CGI;

my $blast_type = $cgi->param('program');
my $database = $cgi->param('database');

etc etc...where program and database are the names of textfields on the form

adam




At 10:05 AM -0500 4/14/2000, Frances K. Schuetz wrote:
>Hi,
>I am a newcomer to this list and pretty new to MacPerl, too.
>
>I have been struggling with a problem which I am sure is really simple,
>but I can't seem to find the answer anywhere.
>
>I am having trouble getting my script to read STDIN. I am trying to read
>the data from a form using POST. It works fine if I use GET and don't have
>to use STDIN, but if I try to use POST, it acts like there is no data to
>read. Even
>
>while (<STDIN>) {
>   print "$_";
>}
>
>isn't producing anything.
>
>Here is my code:
>
>read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
>@pairs = split(/&/, $buffer);
>foreach $pair (@pairs) {
>     ($name, $value) = split(/=/, $pair);
>     $value =~ tr/+/ /;
>     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>     $FORM{$name} = $value;
>}
>
>I have tried everything I can think of including getting cgi-lib.pl and
>using the ReadParse subroutine from there, which does essentially the same
>thing as my code, but I can't get it to read the form data no matter what
>I've tried.
>
>I found a couple places on the web where people were complaining of
>similar problems, but I haven't found an answer. This code works perfectly
>fine in Perl on UNIX, and I don't understand why my MacPerl doesn't seem
>to understand STDIN.
>
>I am using MacPerl 5 under WebStar v. 3.0.2.
>
>Looking forward to any input!
>
>Thanks :)
>Frances Schuetz
>fschuetz@indiana.edu
>
>
>
># ===== Want to unsubscribe from this list?
># ===== Send mail with body "unsubscribe" to macperl-request@macperl.org

-- 


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org