CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
open file



Mar 7, 2000, 6:27 AM

Post #1 of 5 (1089 views)
open file Can't Post

my server is running windows NT
here is my problem:
i wrote a perl script that read and parses and saves to a file as this: open(HAMBO, ">>nm.log" when i go to the nm.log to retrive the user input...THERE IS NOTHING THERE!!! help please...also if my server is running windows NT..what header should i use if not #!/usr/perl?????


Mar 7, 2000, 11:32 AM

Post #2 of 5 (1089 views)
Re: open file [In reply to] Can't Post

You should post more of you code to let us see what is happening but on your system you should write to a file as so:

use CGI qw(:cgi);
use CGI::Carp qw(fatalsToBrowser);

open(FILE, ">>nm.log") or die("$!");
print FILE "log info here\n";

With using the you allow yourself easy error checking. Now if the script cannot open the file it will come back with an error saying it could not open it.

As for your shebang you should put something like: #!c:\path\to\perl
NT systems sometimes ignore this and I am not sure what type of server that is run on NT systems that does but it is good practice to add the shebang any way.

Hope this helps,



Mar 7, 2000, 12:12 PM

Post #3 of 5 (1089 views)
Re: open file [In reply to] Can't Post

The problem was due to the fact that if you copy the following text from this forum, you will get a | followed by a space followed by a |, not a | followed by a |:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

open(FOO, ">bar") &#0124; &#0124; die;

And to Perl, that ends up being a syntax error. UBB folk -- any idea as to why &#0124; &#0124; gets a space inserted in it?


Mar 7, 2000, 3:31 PM

Post #4 of 5 (1089 views)
Re: open file [In reply to] Can't Post


for a header on a nt you dont put the c: in header


I have win95 and i installed apache and perl on my computer.. so the header would be


you dont put the c:/ in a header.



Mar 8, 2000, 12:29 PM

Post #5 of 5 (1089 views)
Re: open file [In reply to] Can't Post

Hi Japhy

I know what you mean by the | | seperating when copied and paste onto a txt file. I dont know why that is-> strang though



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives