> As you said before, I now need
>
> [% sections = [] %]
>
> in my template that contains the WRAPPER. I'd like to understand why a
> simple stash set ( $stash->set('foo', 'baz') ) works, but I need to
> pre-define the array.
This isn't because of localization (as your scalar example shows), but
due to a small bug in the stash: the stash always creates a hash if the
lvalue (left-hand-side) doesn't exist, even if the key is numeric.
For example, if you do this:
[% foo.0 = "test"; %]
then foo is a hashref with a single key "0" whose value is
"test", rather than an arrayref whose 0 index is "test". The
workaround is to predefine an empty array, which my previous
suggestion inadverently accomplished.
Instead of doing this in the template you could fix this in the
filter: do a $stash->get() to check if "sections" is an arrayref;
if not, $stash->set() it to an arrayref, otherwise set the index
as before.
Craig