sub f { my @a; tie @a, 'SomeClass' if $_[0]; g(\@a); return [ @a ]; }