%perlcode %{ sub getAllVariants { my ($self) = @_; my $fv = FooVariants->new($self); my $aref = []; while ( my $foo = $fv->getNext() ) { $foo->ACQUIRE(); # C++ code does not delete this, so ensure delete_ method is called push( @$aref, $foo ); } return $aref; } %}