Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: CGI::Application/HTML::Template problem

by kutsu (Priest)
on Jan 12, 2006 at 17:55 UTC ( #522765=note: print w/replies, xml ) Need Help??


in reply to CGI::Application/HTML::Template problem

If you tryed to print "item" outside the template loop I bet it would print. This is because associate => $q is the same as doing $template->param(ITEM => $q->param('item')) for every param returned by cgi and TMPL_LOOPs introduce their own scope and can't use variables from outside the loop. If you set global_vars => 1 it should work.

Btw. in order to find I simplify your code by trying it without CGI::Application:

script: #!/usr/bin/perl use DBI; use HTML::Template; use CGI; my $q = CGI->new(); my $dbh = DBI->connect('DBI:Pg:dbname=testdb', '', ''); $dbh->{RaiseError} = 1; $aref = $dbh->selectall_arrayref( q/select foo, bar from test_table wh +ere id = ?/, { Slice => {} }, $q->param('id') ); $dbh->disconnect; my $template = HTML::Template->new(filename => 'test.tmpl', associate +=> $q, global_vars => 1); $template->param(TEST_LOOP => $aref); print $template->output(); template: id = <TMPL_VAR NAME=ID> <!--remove global_vars and only this first ID will print--> <TMPL_LOOP NAME=TEST_LOOP> <p> id: <TMPL_VAR NAME=ID> <br \> foo: <TMPL_VAR NAME=FOO> <br \> bar: <TMPL_VAR NAME=BAR> </p> </TMPL_LOOP>

Replies are listed 'Best First'.
Re^2: CGI::Application/HTML::Template problem
by stonecolddevin (Vicar) on Jan 12, 2006 at 22:30 UTC
    global_vars was exactly what i was looking for...thanks so much kutsu, all!!!
    meh.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://522765]
help
Chatterbox?
[muthusathish]: Hi All i need a help
[Eily]: hello muthusathish, we have many helps here
[muthusathish]: i have a perl based dll, how to decompile
[hippo]: :-D
[Eily]: you mean a dll where the SW was written in perl? That sounds unlikely
[muthusathish]: please help me regarding this
[hippo]: Easier just to go and look at the source, no?
[Eily]: mostly because perl isn't compiled in the usual sense of the meaning, you can't execute the opcodes directly, you need the perl engine
[muthusathish]: i dont have the environment too, but i need to get the logics so that i can re-wite
[Eily]: what makes you think your dll is "perl based" ?

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2018-02-23 09:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (301 votes). Check out past polls.

    Notices?