[Catalyst] assigning vars to $c-stash

2007-03-12 Thread Octavian Rasnita

Hi,

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;

Can I use something else than

foreach(keys %$hash) {
$c-stash-{$_} = $hash-{$_};
}

Thank you.

Octavian


___
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/


Re: [Catalyst] assigning vars to $c-stash

2007-03-12 Thread Carl Franks

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.

Cheers,
Carl

___
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/


Re: [Catalyst] assigning vars to $c-stash

2007-03-12 Thread Matt Lawrence

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/


Re: [Catalyst] assigning vars to $c-stash

2007-03-12 Thread Robert 'phaylon' Sedlacek

Octavian Rasnita 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;

Can I use something else than

foreach(keys %$hash) {
$c-stash-{$_} = $hash-{$_};
}


Just

  $c-stash( %$hash );

should do it, iirc.

--
# Robert 'phaylon' Sedlacek
# Perl 5/Catalyst Developer in Hamburg, Germany
{ EMail = ' [EMAIL PROTECTED] ', Web = ' http://474.at ' }

___
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/


Re: [Catalyst] assigning vars to $c-stash

2007-03-12 Thread Eden Cardim

On 3/12/07, Robert 'phaylon' Sedlacek [EMAIL PROTECTED] wrote:


   $c-stash( %$hash );


$c-stash( $hash );

is a little bit faster...

--
Eden Cardim
Instituto Baiano de Biotecnologia
Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas
Laboratório de Bioinformática
--
you seem to think that 'close enough' is close enough...
please learn to be 'literal' around programming.
merlyn - on irc.freenode.net#perl

___
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/


Re: [Catalyst] assigning vars to $c-stash

2007-03-12 Thread Robert 'phaylon' Sedlacek

Eden Cardim wrote:


$c-stash( $hash );

is a little bit faster...


Correct.

--
# Robert 'phaylon' Sedlacek
# Perl 5/Catalyst Developer in Hamburg, Germany
{ EMail = ' [EMAIL PROTECTED] ', Web = ' http://474.at ' }

___
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/


Re: [Catalyst] assigning vars to $c-stash

2007-03-12 Thread Octavian Rasnita

Thank you all for your solutions. I think this is the most simple.

Octavian

- Original Message - 
From: Eden Cardim [EMAIL PROTECTED]

To: The elegant MVC web framework catalyst@lists.rawmode.org
Sent: Monday, March 12, 2007 2:39 PM
Subject: Re: [Catalyst] assigning vars to $c-stash


On 3/12/07, Robert 'phaylon' Sedlacek [EMAIL PROTECTED] wrote:


   $c-stash( %$hash );


$c-stash( $hash );

is a little bit faster...

--
Eden Cardim
Instituto Baiano de Biotecnologia
Núcleo de Biologia Computacional e Gestão de Informações Biotecnológicas
Laboratório de Bioinformática
--
you seem to think that 'close enough' is close enough...
please learn to be 'literal' around programming.
merlyn - on irc.freenode.net#perl

___
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/ 



___
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/