[JaxPM] RE: Code

j proctor jproctor at oit.umass.edu
Sun Dec 3 11:20:14 CST 2000


On the jacksonville-pm-list; Jax.PM'er j proctor <jproctor at oit.umass.edu> wrote -



> Okay I'm lost.  I can't seem to figure what's wrong. I'm getting the all
> too popular script headers but can pin point it to exactly where.  Any
> ideas?

1.  If you haven't already, try running it from the command line.  You can
pick out all sorts of interesting things that way.  The CGI module detects
this, too, and you can enter name=value pairs, one per line, as if the
form submission were coming from STDIN.  Press ^D (on most systems) to end
input.

> #!/usr/bin/perl -w
> use CGI;
> use FileHandle;
> 
> $cgiobject = new CGI;
> $from = $cgiobject -> param ("from");
> $email = $cgiobject -> param ("email");
> $subject = $cgiobject -> param ("subject");
> $body = $cgiobject -> param ("body");
> $htmlprint = "Content-type: Text/html\n\n";

"text/html" may need to be all lower case.  I don't know if the server or
the browser is case-sensitive, but it's how I've always seen MIME types.


> # first let me see if this user exists
> unless (-e "/path/$from")
> 	{
> mkdir ("/path/$from", 0777) || die ("$!\n");
> chdir ("/path/$from");
> $fh = new FileHandle "> datafile";
> $mode = 0777; chmod $mode, 'datafile';
> }
> 
> 
> print "$htmlprint";
> print "<HTML><BODY BGCOLOR=\"BLACK\" TEXT=\"WHITE\">";

Stylistic note:  Since the contents of this line don't change, you could
have used single quotes and avoided having to \ the internal ones.  It
took me a long time to warm up to it, but a better practice, used by many
who have significantly more experience than both of us put together, is to
use qq().  You can use it on every line, since it does variable
interpolation, and you can use beginning and end markers other than () if
you're going to have those embedded in the string.

> open (MAIL, "|/usr/lib/sendmail -oi $email");

Sometimes, sendmail is configured to be kinda fussy about who it lets send
messages to whom.  I don't think this is your problem, but running it by
hand will show you if it is.  I've started using Net::SMTP instead,
because it doesn't rely on a particular daemon to be in place.


j


Jax.PM Moderator's Note:
This message was posted to the Jacksonville Perl Monger's Group listserv.
The group manager can be reached at -- owner-jacksonville-pm-list at pm.org
to whom send all praises, complaints, or comments...




More information about the Jacksonville-pm mailing list