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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
file writing problem.

 



iceman
Deleted

Sep 8, 2000, 7:44 PM

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

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

#!/usr/local/bin/perl

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

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

#End write.pl

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.


Kanji
User / Moderator

Sep 8, 2000, 8:46 PM

Post #2 of 2 (239 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 "...";
}</pre><HR></BLOCKQUOTE>

 
 


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

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