logo       

Re: using __DATA__ section as template in module: msg#00007

Subject: Re: using __DATA__ section as template in module
On Sat, 2 Oct 2004 grazer@xxxxxxxxxxxx wrote:

>
>
> I have been having some trouble with a module I am working on that requires
> HTML::Template.
>
> I am trying to use the __DATA__ section of the module as a default template to
> fall back on if one is not supplied to my constructor.
>
> Here is a simple script that illustrates the issue:
>
> [ken@darkstar DBWebForm]$ cat Foo.pm
> #!/usr/bin/perl
> use strict;
> use warnings;
> Foo->run();
> package Foo;
> use HTML::Template;
> sub run{
>         my @html = <DATA>;
>         my $template = HTML::Template->new(arrayref => \@html,
> die_on_bad_params=>1, strict=>1);
>         $template->param(VALUE=>'xx');
>         print $template->output;
> }
>
> 1;
> __DATA__
> <html>
> <head>
> </head>
> <body>
> <TMPL_VAR NAME=VALUE>
> </body>
> </html>
> [ken@darkstar DBWebForm]$ ./Foo.pm
> <html>
> <head>
> </head>
> <body>
> xx
> </body>
> </html>
> [ken@darkstar DBWebForm]$ perl -MFoo
> HTML::Template->new() : Syntax error in <TMPL_*> tag at
> /fake/path/for/non/file/template : 5. at
> /usr/lib/perl5/site_perl/5.8.0/HTML/Template.pm line 2288, <DATA> line 7.
> Compilation failed in require, <DATA> line 7.
> BEGIN failed--compilation aborted, <DATA> line 7.
>
>
> Anyone ideas on what is going on? Any suggestions welcome.
>
> Thanks in advance,
> -Ken

FWIW, I don't get any errors when I run that (perl, v5.6.1).

--Brad


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe