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:
file writing problem.



Sep 8, 2000, 7:44 PM

Post #1 of 2 (257 views)
file writing problem. Can't Post

I can't work out what is wrong with this code:


$location = "fullpath.../file.txt";

open(FILE, ">$location");
print FILE "Test";


This code works when run locally on my HD, but when I run it on my server, it returns nothing. I've checked the read/write permissions and thats not the problem. Can anyone help?

Thanks in advance, iceman.

User / Moderator

Sep 8, 2000, 8:46 PM

Post #2 of 2 (257 views)
Re: file writing problem. [In reply to] Can't Post

Always, always, always check the return value from something from open(): it saves your sanity.

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

# Kill the script
open FILE, $file
or die "Can't open $file because $!";

# Just complain.
if ( open FILE, $file ) {
&do_stuff_with( <FILE> );
close FILE;
} else {
warn "Can't open $file because $!";
# or print "...";


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

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