Closed Thread Icon

Topic awaiting preservation: Perl :) Problem Pages that link to <a href="https://ozoneasylum.com/backlink?for=11919" title="Pages that link to Topic awaiting preservation: Perl :) Problem" rel="nofollow" >Topic awaiting preservation: Perl :) Problem\

 
Author Thread
WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 10-23-2001 04:02

Been a while since I have used perl, and it would be my luck that my favorite Perl links are now dead, and my book is 350 miles away.

So, appologies for presenting you all with such a simple problem.

Problem being the file is not being input correctly. So there must be something that I am doing wrong in inport statement, however I just don't know what it is.

Am I unable to read files that are outside the CGI-BIN directory? I don't think that is the case, I think it would have to be something a bit simpler than that...


code:
#!/usr/bin/perl

use CGI ;
use RESELLER ;

my $chkbackurl = RESELLER::chkbackurl ;
my $cgi = new CGI ;

$headerTemplate = $ENV{DOCUMENT_ROOT} . "/templates/header.html";
$footerTemplate = $ENV{DOCUMENT_ROOT} . "/templates/footer.html";

open(F, "< $headerTemplate");
$hTemplate = <F>;
close(F);

open(F, "< $footerTemplate");
$fTemplate = <F>;
close(F);

print $cgi->header ;
print $hTemplate ;
print "\n\n" ;
print $cgi->start_form(-action=>"****", METHOD=>"post") ;
my $HTML =<<EndOfHTML ;
Type in the domain you want to check if available : <br>
<INPUT TYPE="text" NAME="domain" SIZE="40" MAXLENGTH="64">
<SELECT NAME="tld">
<OPTION VALUE=".com">.COM
<OPTION VALUE=".net">.NET
<OPTION VALUE=".org">.ORG
</SELECT>
<INPUT TYPE="hidden" NAME="url" VALUE="$chkbackurl">
<BR>
<INPUT TYPE=SUBMIT NAME=Check VALUE=Check>
EndOfHTML

print $HTML ;
print $cgi->end_form ;
print "\n\n" ;
print $fTemplate ;



Piper
Paranoid (IV) Inmate

From: California
Insane since: Jun 2000

posted posted 10-23-2001 04:34

Hi WarMage,

It looks like it should work to me. Have you checked the file permissions on the templates? Have you checked your error logs? If you cant get to the error logs you could try to put a use CGI::Carp qw/fatalsToBrowser/; at the top of the script and add a or die ?Unable to read open $headerTemplate. Reason: $!?; to the end of your open statements and see if you can get a better error message. Hope that helps.

Regards,
Charlie

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 10-23-2001 05:34

I added the or die function, and nothing has changed, at all.

I am not recieving any errors...

The result I get from the page is:

code:
<!-- DumpPage --> <html>


<FORM METHOD="post" ACTION="****" ENCTYPE="application/x-www-form-urlencoded">
Type in the domain you want to check if available : <br>
<INPUT TYPE="text" NAME="domain" SIZE="40" MAXLENGTH="64">
<SELECT NAME="tld">
<OPTION VALUE=".com">.COM
<OPTION VALUE=".net">.NET
<OPTION VALUE=".org">.ORG
</SELECT>
<INPUT TYPE="hidden" NAME="url" VALUE="****">
<BR>
<INPUT TYPE=SUBMIT NAME=Check VALUE=Check>
</FORM><p>&nbsp;</p>



I have permissions correct as well...

Piper
Paranoid (IV) Inmate

From: California
Insane since: Jun 2000

posted posted 10-23-2001 06:33

Try to read the data in with something like this:

[code]
open (FH, "< $ENV{DOCUMENT_ROOT}/templates/header.html") or die "Can't read open: $!";
read (FH, my $hTemplate, -s FH);
close FH;
[\code]

Will $fTemplate = <F>; read the entire file in without looping though the F filehandle with something like while ( <F> ) {$hTemplate .= $_}? Just a couple more ideas for you.

Regards,
Charlie



[This message has been edited by Piper (edited 10-23-2001).]

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 10-23-2001 08:23

The first example worked for me. Thank you so much!

« BackwardsOnwards »

Show Forum Drop Down Menu