in reply to Basic, writing to a file

When you open your file with ">$sql_log", you're telling perl to open the file in write-only mode with the preceding > sign, which is probably what you want.

However, when you do while (<FH>) you're telling perl to try to read from the file, which you've just told it it can't do, and thus you get your error. Instead, you probably want:

my $sql_log = "c:\\temp\\sqllog.out"; open (FH, ">$sql_log") or die "can't open file $! \n"; print FH "test"; close FH;
to simply write one line out to the file. Update yea, forgot the FH in the print line.

If you're looking to do something more complex, let us know what you're trying to do as there's probably more to this code than what you've given us.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re: Re: Basic, writing to a file
by suaveant (Parson) on Nov 27, 2001 at 19:42 UTC
    I think masem meant
    print FH "test";

                    - Ant
                    - Some of my best work - (1 2 3)

Re: Re: Basic, writing to a file
by dreman (Acolyte) on Nov 27, 2001 at 19:48 UTC
    Hey Masem, thanks for the information, I also found out why it was a problem before reading (while statement) your reply. dreman