Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get this dispalyed in perl script 1

Status
Not open for further replies.

khoont

Programmer
Mar 9, 2001
10
US
<!--#include virtual=&quot;../mait/includes/hd_default_ma.inc&quot;-->

anyone have idea ,how to get the content of hd_default_ma.inc file on the webpage through perl script...
thanks
 
I'm not sure of what you mean.

You can use Perl in two different ways: CGI or ASP.

Which one do you plan on using?


Thierry
 
what i mean is this is html written between print<<bookmark ; and bookmark; statement in perlscript.
but this purticulor html statemnt doesnt expand while you run the perl script.
so my question is ...how to get that content of .inc file to bring it in perlscript while its running. so can get all the things displayed on web page.

<!--#include virtual=&quot;../mait/includes/hd_default_ma.inc&quot;-->

i dont understand why perl doesnt understand this include stament while running the script. it just leaves it as comment statement while you check up with view source on netscape or msie browser.

please help.
thanks
 
that include virtual statement isn't a perl command, that's why it's leaving it alone. if you just need to include a file's contents, try something like this:[tt]
open FILE, &quot;< ../path/to/the/file.ext&quot;;
@file = <FILE>;
close FILE;
print @file;[/tt]

and can move the print wherever you need it, and it will print the entire contents of the file. is this what you need? &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Your use of the term 'perl script' is ambiguous. Are writing a CGI script using Perl or are you write 'perl script' (like javascript, only, Perl) to use in a browser that understands it? I assume you are doing this in a CGI context. Otherwise, you would just put the include in plain old HTML. ??

If you are doing this in a CGI context, then it won't work. The web server (Apache, anyway, not sure about IIS or others), must interpret the Perl code, generate something a browser will understand and send it to the browser. The web server will not understand the meaning of the include statement, and, I don't know why, but, the browser will not make any attempt to evaluate the <!--# include....-->. Coincidentally, I just answered the same question in the CGI forum, like this....

Code:
#!/usr/local/bin/perl
print &quot;Content-type: text/html\n\n&quot;;
print &quot;<HTML><HEAD><TITLE>A NEW CGI PAGE</TITLE></HEAD>\n&quot;;
print &quot;<BODY><P>&quot;;

# open file you want to include and print it.
open(IPF,&quot;<../mait/includes/hd_default_ma.inc&quot;) 
        or print &quot;Failed to open include file, $!\n&quot;;
while (<IPF>) { print; }
close IPF;

print &quot;</P></BODY></HTML>&quot;;


HTH


keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top