On Sat, 11 Apr 2015 21:20:22 -0700 SSC_perl <p...@surfshopcart.com> wrote:
> Could someone please explain the difference between: > > %{$self->{'DATA'}} = () } %{ $self->{'DATA'} } = (); > > and > > $self->{'DATA'} = {} > > I was told that they are equivalent, but they're not. One > works and the other doesn't, so they must be different. Here's the > context: No, they are not the exact same, as this snippet of code shows: my $self = { DATA => 1 }; %{ $self->{'DATA'} } = (); If $self->{DATA} does not exist, then they are the same because Perl does autovivification. To get the first one to behave like the second, you should delete $self->{DATA} delete( $self->{DATA} ); %{ $self->{'DATA'} } = (); -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/