> Hey, can anyone repeat this or explain what obvious mistake I made?

Well, your example could easily be repeated, but it works just like it
should ;)


> > I've got a plugin that returns an array ref.  Not sure what 

Here's the mistake. Your plugin returns not an arrayref, but a coderef! So
when you try to "unshift" something into that coderef - that does not work.

When you use Dumper to look at your data, the code referenced by "first" is
executed, and Dumper gets it's result. E.g.

> >         Dumper.dump( first );

works like "Dumper.dump( first() )"

When you assign, 

> >         x = first;

the code is also executed, and "x" gets result of this code (like "x =
first()").


So if you want to return arrayref, you should change your plugin code to
return it, not code ref :)

package Template::Plugin::Arrayref;
use strict;
use warnings;
use Data::Dumper;

use base 'Template::Plugin';

sub new {
        return [
            [
                { one => 1, two => 2, },
                { three => 2, four => 4, },
            ],
            [
                { xone => 1, xtwo => 2, },
                { xthree => 2, xfour => 4, },
            ],
        ];
}

1;


-- 
Sergey Martynoff


_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to