M
maxwells
Dear Friends,
There is a line of code in my perlscript which is mysterious for the
following reason: it doesn't appear to do anything useful, but if I
remove it the script stops working.
This is my script, a simple mailer which is accessed by AJAX. It
receives a POST with the contents of a two-element form:
#!/usr/bin/perl -w
use CGI;
$query = new CGI;
$sender = $query->param('s');
$message = $query->param('m');
$mailprog = '/usr/lib/sendmail';
open(MAIL,"|$mailprog -t");
print MAIL "To: donald\@duck.com\n";
print MAIL "From: $sender\n";
print MAIL "Subject: AJAX Mailer\n\n";
print MAIL "$message";
close (MAIL);
$remotehost = $query->remote_host(); # <----- this is the mysterious
line
print $query->header;
print "<p>Your message was received.</p>";
If I leave the "$remotehost =" line in, the print commands work, and
the "received" message is posted on the web page by
xmlHttpReq.responseText
If I remove the "$remotehost =" line, which was only there because it
was useful in a completely different context, the "received" message
never appears.
I have now tried this on two linux servers, and it behaves the same way
on each.
I'm sure there is a perfectly good reason for this, but I don't know
what it is. Would the experts of comp.lang.perl please lend me the
benefit of their collective wisdom?
Thanks a lot,
John
There is a line of code in my perlscript which is mysterious for the
following reason: it doesn't appear to do anything useful, but if I
remove it the script stops working.
This is my script, a simple mailer which is accessed by AJAX. It
receives a POST with the contents of a two-element form:
#!/usr/bin/perl -w
use CGI;
$query = new CGI;
$sender = $query->param('s');
$message = $query->param('m');
$mailprog = '/usr/lib/sendmail';
open(MAIL,"|$mailprog -t");
print MAIL "To: donald\@duck.com\n";
print MAIL "From: $sender\n";
print MAIL "Subject: AJAX Mailer\n\n";
print MAIL "$message";
close (MAIL);
$remotehost = $query->remote_host(); # <----- this is the mysterious
line
print $query->header;
print "<p>Your message was received.</p>";
If I leave the "$remotehost =" line in, the print commands work, and
the "received" message is posted on the web page by
xmlHttpReq.responseText
If I remove the "$remotehost =" line, which was only there because it
was useful in a completely different context, the "received" message
never appears.
I have now tried this on two linux servers, and it behaves the same way
on each.
I'm sure there is a perfectly good reason for this, but I don't know
what it is. Would the experts of comp.lang.perl please lend me the
benefit of their collective wisdom?
Thanks a lot,
John