Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Template toolkit Adding Values to Variable

by merlyn (Sage)
on Mar 01, 2010 at 18:21 UTC ( [id://825977]=note: print w/replies, xml ) Need Help??


in reply to Template toolkit Adding Values to Variable

[% totalprice + ff %] <---- 2 ------>
That doesn't change the value of totalprice. Did you mean GET totalprice = totalprice + ff perhaps?

-- Randal L. Schwartz, Perl hacker

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Replies are listed 'Best First'.
Re^2: Template toolkit Adding Values to Variable
by seekperlwisdom (Acolyte) on Mar 01, 2010 at 19:08 UTC

    Its my mistake i am changing it right now. i didnt write the proper code when i was makig simplified version to make my question more clear. but in fact it is [% totalprice = totalprice + ff %]. it seems like as i answered to " CountZero " , 'totalprice' variable become private when it is inside the

    [% FOREACH %]
    block because i printed the value inside the block and it does change but as soon it comes out of the block it retain the initial value ( the one before the [% FOREACH %]). i have tried to use [% BLOCK PROCESS %] but it still does not make any differnce. i might need to get the value from the script.

    But in your answer,dont you think it should be 'SET' what i have red in the ' Perl Template Toolkit ' book.

    thanks
      I deliberately used GET because I want to execute the calculation and interpolate it into the text. Without GET, you're chosing one or the other.

      -- Randal L. Schwartz, Perl hacker

      The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

        Thanks for clearing that for me. But i am stil stuck. i tried the GET method but still same result. i can get the value out of it in the [% FOREACH %] block but as soon it comes out of block it goes back to what it was before the block started.

        should i assume that in TT ,From [% FOREACH %] block , we cannot export the value which i believe is possible in PERL itself.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://825977]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-03-28 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found