Front page | perl.beginners |
Postings from April 2002
RE: file handles in cgi
Thread Previous
|
Thread Next
From:
David Gray
Date:
April 3, 2002 06:23
Subject:
RE: file handles in cgi
Message ID:
000d01c1db1a$f6442be0$7800a8c0@3b2.com
> this is the perl script : abc.pl(say) -- this is in my cgi-bin...
>
> #!/usr/bin/perl
> print "content-type: text/html\n\n";
>
> open (IN, ">abc.txt");
> $x = ($inputs{name});
> print IN $x;
> close (IN);
>
> open (IN, "abc.txt");
> @arr = <IN>;
> print @arr;
> close (IN);
>
> and this is the html ... abc.html(say) in the httpd/html ....
>
> <html>
> <head></head>
> <body>
>
> <form method="post" action="/cgi-bin/abc.pl">Enter the name:
> <input type="text" name="name">
> <input type="submit" value="click">
> </form>
>
> </body>
> </html>
>
>
> if i run the .pl from command prompt with perl abc.pl , i t
> works fine and the abc.txt is created..now if i delete the
> abc.txt and run the script from the browser, the abc.txt is
> not created at all. i think there is something else that i
> might have to configure to be able to use files in cgi...help
> please...
You need to print html headers when you're printing to a browser, i.e.
print "Content-type:text/html\n\n";
-dave
Thread Previous
|
Thread Next