On Apr 12, 2015 12:23 AM, "SSC_perl" <[email protected]> wrote:
>
> Could someone please explain the difference between:
>
> %{$self->{'DATA'}} = () }
>
The hashref of key "DATA" equals an empty list. The trailing bracket is the
end of the else block. $self is also probably blessed (an object).
ref($self->{DATA}) eq 'HASH'
> and
>
> $self->{'DATA'} = {}
>
Same
> 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:
>
> --------------------
>
> sub empty_db {
> my $self = shift;
> if ($self->{'USEDBM'} eq 'sql') {
> $self->{'SQL'}->do("DELETE from $self->{'DB'}") or
$self->{'ERRMSG'} .= $DBI::errstr and return;
> }
> else { %{$self->{'DATA'}} = () }
> # else { $self->{'DATA'} = {} } # This does nothing
> }
>
IDK where this is from, but I'd question the wisdom of running this code...