Gossamer Forum
Home : General : Perl Programming :

Opening Files :(

Quote Reply
Opening Files :(
Ok, can someone please tell me why this code won't work. I for the life of me cannot see the error. I've managed to narrow the error down to this piece of code, so I'm hoping someone can see the error I can :)

Code:
open(WEBMASTER,"/home/pokemon/public_html/includes/free-webmaster.txt") || die "Error: $!";
@free_webmaster = <WEBMASTER>;
close(WEBMASTER);

open(MAIN_MENU,"/home/pokemon/public_html/includes/free-main-menu.txt") || die "Error: $!";
@main_menu = <MAIN_MENU>;
close(MAIN_MENU);

open(FREE-MAILINGLIST,"/home/pokemon/public_html/includes/free-mailinglist.txt") || die "Error: $!";
@free_mailinglist = <FREE-MAILINGLIST>;
close(FREE-MAILINGLIST);

open(COPYRIGHT,"/home/pokemon/public_html/includes/copyright.txt") || die "Error: $!";
@copyright = <COPYRIGHT>;
close(COPYRIGHT);
I'm hoping when I get back later I will be able to see it, but I'm not holding my breath Frown.

Any help will be much appreciated Smile

Andy

webmaster@ace-installer.com
http://www.ace-installer.com
Quote Reply
Re: Opening Files :( In reply to
It would be helpful if you said WHY it didn't work.

Also, opening and closing files is a basic fuction. You should visit perl.com to learn the syntax if you are having trouble, or why not use TELNET (like you tell others to do).

perl -c script.cgi

...or check your error log - after all that is the PURPOSE of die $!

Installs:http://wiredon.net/gt
FAQ:http://www.perlmad.com

Quote Reply
Re: Opening Files :( In reply to
Check your web server error logs. It should highlight the error there, and tell you on excatly what line the error is at.

Have you tried <FREE_MAILINGLIST> instead of <FREE-MAILINGLIST>?

Have you tried a process of trial and error? Try and place only 1 file handle in the script and see at what file handle the error appears.

How do you know that the error is generated from this snippet of code and not in any other part of your program?

Rgds
Wil Stephens


Quote Reply
Re: Opening Files :( In reply to
Yeah. Don't worry. It was a typo in the HTML page. I was calling @copyrght instead of @copyright, so it was looking for an array with that name, and producing an error Frown

Thanks Anyway

Andy

webmaster@ace-installer.com
http://www.ace-installer.com