hello all,
Once again I am here to ask for wisdom to be bestowed on me. I am obviously new to perl (switching from vb), and I am having some novice troubles that the book won't fix. I need some experienced eyes to glance over my script. I am attempting to write info from a form to a txt file on my NT server. When I comment out the "write file section", my script works, but when the "write file section" is not commented out, I get an error saying, "/path/cgi-bin/script.pl produced no output." Any help would be greatly appreciated.
use CGI qw/:standard/;
my $name = param(Name);
my $address1 = param(Address1);
################################################################
# write info to a file
open(FILE, ">>/data.txt") || die "The database could not be opened";
flock(FILE, 2);
print FILE "$name\n";
flock(FILE, 8);
close(FILE);
################################################################
$expires = "Tuesday, 1-Dec-2099 16:00:00 GMT";
$path = "";
$server_domain = "http://www.mydomain.com";
print "Set-Cookie: ";
print "Name", "=", $name, "; expires=", $expires,
"; path=", $path, "; domain=", $server_domain, "\n";
print "Address", "=", $address1, "; expires=", $expires,
"; path=", $path, "; domain=", $server_domain, "\n";
print header;
print "<body>";
print "The following data has been sent:";
print "<font color=blue>Name:</font> $name <br>";
print "<font color=blue>Address:</font> $address1 <br>";
update (broquaint): title change (was Writing to files)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.