[Catalyst] difficulty in assigning an array to a stash
Mark Smith
smitty at gmail.com
Sun Nov 11 16:40:31 GMT 2007
> But if I
> define the array first and then assign it to the stash, ( like 'my
> @options = qw/1 2 3 4 5 6 7/; $c->stash->{myoptions} = @options;) I am
> getting only the last value in the tt2 template. How can I get all the
> values in the array into the stash without having to do it explicitly?
That's because you're stuffing an array in a scalar. Or trying. Do this:
my @options = qw/1 2 3 4 5 6 7/;
$c->stash->{myoptions} = \@options;
Or, for a literal translation of your first code:
my $options = [ qw/1 2 3 4 5 6 7/ ];
$c->stash->{myoptions} = $options;
Note the differences.
While you're at it, try "perldoc perlreftut" and "perldoc perlref" for
more information on references.
Good luck.
--
Mark Smith / xb95
smitty at gmail.com
More information about the Catalyst
mailing list