[Catalyst] info basic stash problem...maybe i am too tired this sunday

Igor Longagnani i.longagnani at synervis.it
Sun Jan 14 23:03:37 GMT 2007


As supposed i wastoo confused in my question, surely it wont get any
better ..anyway let's try :)

1) I am into a controller  and I have an hashref that  I punt into the
stash : $c->stash->{allegati} = $chiavi
2) in the template i wanna print out some of the values of the $chiavi
referenced hash
3) the values to printed out depend on keys which are built at runtime
inside the page template  ( lets pretend i take the keys from another
data structure )


now the question:

if $c->stash->{allegati} is a reference to a plain hash  (  e.g. 
{'3-bc-4' => 'alpha', ....,'t-rt-7' => 'omega'} ) and i have 1 key of
that hash in a variable of the page template, how do i print its hash
value ?

[% k % ]               # k = '3-bc-4'
[% allegati %]       # prints   HASH(0x2398423794 whatever)
[% allegati.k %]   # is nullor  doesnt work as i expected --->  how can
I print out 'alpha'?

I do beg your pardon for any miscomprehension due to my lack of
vocabulary or inesperience.
Thanks again for your already precious efforts in trying to understand
... :)

i.





Ash Berlin ha scritto:
> Igor Longagnani wrote:
>> Hi, newbie here...
>> i thought i had understood stash behaviour... but prolly not :)
>>
>> I can use it together with DBIx::Class resultsets and so on, BUT now i
>> would like to put  such an hashref
>>
>> $chiavi= {
>>           'ka-111-234-586' => '0',
>>           'ka-90-85-349' => '0',
>>           'ka-5-21-629' => '0',
>>           'ka-1-406-194' => '0',
>>           'ka-111-194-479' => '1',
>>           'ka-1-451-540' => '0',
>>           'ka-1-254-610' => '0',
>>           'ka-1-216-571' => '0',
>>           ... more data...
>> };
>>
>> into the stash  e.g.   $c->stash->{allegati} = $chiavi;
>> then  i would like to use something like
>>
>> <! -- standard cycle through some kind of data -->
>> [ FOREACH ... %]
>> ...
>> <!-- build one of the key of the hashref 'allegati'   -->
>> [% currentkey = ...%]
>>
>> <!-- use one of the values of the hashref -->
>> [% allegati.currentkey %]
>>
>>
>> The problem is this last [% allegati.currentkey %]  is always empty even
>> if i am sure i am asking for an existing key of the hash ref.
>> What am i doing wrong?
>> I know it is something silly ... but still makes me doubt about my
>> comprehension of the stash
>>
>> Any wise suggestion?
>
> Yes - show us the code for the action and the full template - the info
> you've given isn't enough do divine the problem.
>
> Ash
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
>


-- 
Igor Longagnani c/o Synervis
-------------------------------------------------------------------
e-mail: i.longagnani at synervis.it             phone : +39 059 558442

sede operativa: via Pirandello, 49/51 - 41043 Formigine (Mo) Italia




More information about the Catalyst mailing list