Current location: Hot Scripts Forums » Programming Languages » Perl » Is there a fucntion like include in perl/cgi


Is there a fucntion like include in perl/cgi

Reply
  #1 (permalink)  
Old 01-24-05, 06:09 PM
Tempestshade Tempestshade is offline
Newbie Coder
 
Join Date: Aug 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Is there a fucntion like include in perl/cgi

Is there a fucntion like include in perl/cgi like in php?
__________________
http://www.cashbackhosting.net - Cashback Hosting. Cheap Web Hosting starting at $1.50
Reply With Quote
  #2 (permalink)  
Old 01-25-05, 12:48 AM
PoizOn PoizOn is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Use templates, better. See HTML::Template.
__________________
Hello, i'm russian, that's why my english so bad, but i want discuss about perl :-)
Russian forum about Perl
Reply With Quote
  #3 (permalink)  
Old 01-25-05, 01:10 PM
Tempestshade Tempestshade is offline
Newbie Coder
 
Join Date: Aug 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
hrm.... can u show me how to use that?
__________________
http://www.cashbackhosting.net - Cashback Hosting. Cheap Web Hosting starting at $1.50
Reply With Quote
  #4 (permalink)  
Old 01-26-05, 12:38 AM
PoizOn PoizOn is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Into template file, you can use next command:

<TMPL_INCLUDE NAME="file-name.html">

When you output this template, file - "file-name.html" will be included into your document...

http://html-template.sourceforge.net/ - download this module.

http://html-template.sourceforge.net/article.html - docs

example from me:

template.html:
Code:
  <HTML>
    <HEAD>
       <TITLE>Test Template</TITLE>
    </HEAD>
    <BODY>
       My Home Directory is <TMPL_VAR NAME="home">.
       My Path is set to <TMPL_VAR NAME="path">.
       My include:<br>
    <TMPL_INCLUDE NAME="file-name.html">
    </BODY>
  </HTML>
file-name.html
Code:
        <TABLE BORDER=1>
            <TR>
              <TD><B>Fruit Name</B></TD>
              <TD><B>Color</B></TD>
              <TD><B>Shape</B></TD>
            </TR>
       </TABLE>
script.cgi
Code:
use HTML::Template;

  # open the HTML template
  my $template = HTML::Template->new(
                                                                       filename => 'template.html',
                                                                       path => '/path/to/template'
                                                                         );

  # fill in some parameters in the template
  $template->param(home => $ENV{HOME});
  $template->param(path => $ENV{PATH});

  # send the obligatory Content-Type
  print "Content-Type: text/html\n\n";

  # print the template
  print $template->output;
Try it. It's very usefull.
__________________
Hello, i'm russian, that's why my english so bad, but i want discuss about perl :-)
Russian forum about Perl
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP help... Orchidsdance PHP 8 09-25-04 07:58 PM
Random PHP include brduran PHP 4 08-16-04 06:34 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM
How do I include external script jimpy ASP 3 05-24-04 06:39 AM
include() Dimka PHP 26 09-20-03 07:51 AM


All times are GMT -5. The time now is 04:02 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.