Carl Franks wrote:
On 12/03/07, Octavian Rasnita <[EMAIL PROTECTED]> wrote:
I have a $hash hash reference and I want to add all its elements to the
stash. How can I do this? Do I need to use a loop and assign each element
one by one?

I have seen that it is not possible to use $c->stash = $hash;

%{ $c->stash } = ( %{ $c->stash }, %$hash );
would also work, which combines both hashes.

This is very much a perl references problem - not something cat-specific.

See `perldoc perlref` for more info.

I'm a fan of slicing, no need to construct a new hash:

@{$c->stash}{keys %$hash} = values %$hash;

Matt


_______________________________________________
List: Catalyst@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/

Reply via email to