Either make a copy of the array that was passed to new or simply increase its reference count. Otherwise perl tries to free it, as you see. That doesn't happen if you pass a named reference because the array is still in the same scope and won't get destroyed therefor.
For example it should also work with with an anonymous reference if you store it in another lexical variable:
my @array = 1 .. 3; my $ref = [@array] Test->new($ref);
Cheers, Flo
In reply to Re: Help with XS and anonymous arrays
by rafl
in thread Help with XS and anonymous arrays
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |