Re: Need explanation of code

2015-04-12 Thread shawn wilson
On Apr 12, 2015 8:06 AM, "Shawn H Corey" wrote: > > On Sat, 11 Apr 2015 21:20:22 -0700 > SSC_perl wrote: > > > Could someone please explain the difference between: > > > > %{$self->{'DATA'}} = () } > > %{ $self->{'DATA'} } = (); > > > > > and > > > > $self->{'DATA'} = {} > > > > I w

Re: Need explanation of code

2015-04-12 Thread Shawn H Corey
On Sat, 11 Apr 2015 21:20:22 -0700 SSC_perl 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 ot

Re: Need explanation of code

2015-04-12 Thread Andrew Solomon
Eeeks, Sorry Shlomi, I can't help thinking my German lessons have been counter-productive... A On Sun, Apr 12, 2015 at 10:37 AM, Shlomi Fish wrote: > On Sun, 12 Apr 2015 09:36:00 +0100 > Andrew Solomon wrote: > > > Thank you very much Schlomi - I stand corrected! > > > > You're welcome, Andrew

Re: Need explanation of code

2015-04-12 Thread Shlomi Fish
On Sun, 12 Apr 2015 09:36:00 +0100 Andrew Solomon wrote: > Thank you very much Schlomi - I stand corrected! > You're welcome, Andrew! Just note that my name is spelled "Shlomi" - not "Schlomi". See: * http://www.shlomifish.org/meta/FAQ/#your_name You can also call me "Rindolf": http://www.sh

Re: Need explanation of code

2015-04-12 Thread Andrew Solomon
Thank you very much Schlomi - I stand corrected! Frank, another way of putting what Schlomi has illustrated is that: %{$self->{'DATA'}} = ( foo => 'bar' ); means "change the contents of the hash which $self->{'DATA'} refers to", while $self->{'DATA'} = { foo => 'bar' }; means "change $self->{'

Re: Need explanation of code

2015-04-12 Thread Shlomi Fish
Hi Andrew, On Sun, 12 Apr 2015 07:25:55 +0100 Andrew Solomon wrote: > Hi Frank > > I found the first one rather obscure, but they are equivalent. No - they are not exactly the same. See below: > To prove > this, Data::Dumper is my friend: > > #!/usr/bin/perl > > use strict; > use warnings;

Re: Need explanation of code

2015-04-11 Thread Shlomi Fish
On Sat, 11 Apr 2015 21:20:22 -0700 SSC_perl wrote: > Could someone please explain the difference between: > > %{$self->{'DATA'}} = () } > > and > > $self->{'DATA'} = {} The first line works on the physical reference $self->{'DATA'} and empties it. The second one assigns a new empty refe

Re: Need explanation of code

2015-04-11 Thread Andrew Solomon
Hi Frank I found the first one rather obscure, but they are equivalent. To prove this, Data::Dumper is my friend: #!/usr/bin/perl use strict; use warnings; use Data::Dumper; { my $self; print "selfish self \n"; %{$self->{'DATA'}} = ( foo => 'bar' ); print Dumper $self; } { my $self;

Re: Need explanation of code

2015-04-11 Thread shawn wilson
On Apr 12, 2015 12:23 AM, "SSC_perl" 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->{

Need explanation of code

2015-04-11 Thread SSC_perl
Could someone please explain the difference between: %{$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: sub empty_db {