in reply to Wierdness with a reference to @_
(my preferred approach)sub foo { my $self = shift; my @args = @_; $self->{bar} = ref ( $_[0] ) ? $_[0] : \@args; }
My suspicion is that @_ gets clobbered (or unset) as soon as you leave the subroutine due to internal Special Magic. You're left holding a reference to an empty variable. Either copy the values out of it, or expand it into an anonymous list.sub foo { my $self = shift; $self->{bar} = ref ( $_[0] ) ? $_[0] : [ @_ ]; }
|
|---|