Re: Making variables private

2008-03-06 Thread Jay Savage
[please don't top post] On Thu, Mar 6, 2008 at 10:50 AM, yitzle <[EMAIL PROTECTED]> wrote: > I don't know much about how Perl deals with this stuff, but what > you've done is made a copy of the pointer/reference. > Both variables are referencing the same memory/hash. > What you want to do is co

Re: Making variables private

2008-03-06 Thread yitzle
On Thu, Mar 6, 2008 at 10:50 AM, yitzle <[EMAIL PROTECTED]> wrote: > I don't know much about how Perl deals with this stuff, but what > you've done is made a copy of the pointer/reference. > Both variables are referencing the same memory/hash. > What you want to do is copy the hash, not copy the

Re: Making variables private

2008-03-06 Thread Gunnar Hjalmarsson
Dermot wrote: # Make a local copy of HoH my $ref = $fileSizes; $fileSize is a reference to the HoH, and $ref is nothing but another reference to the very same data structure. You probably want to study the FAQ entry "perldoc -q copy". -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bi

Re: Making variables private

2008-03-06 Thread Chas. Owens
On Thu, Mar 6, 2008 at 10:54 AM, Chas. Owens <[EMAIL PROTECTED]> wrote: snip > use Storable qw; snip > my $copy = thaw(freeze($fileSize)); snip I should really read the docs before I post. This code can be simplified to use Storable qw; my $copy = dclone($fileSize); -- Chas. Owens wonkden.n

Re: Making variables private

2008-03-06 Thread Chas. Owens
On Thu, Mar 6, 2008 at 10:42 AM, Dermot <[EMAIL PROTECTED]> wrote: snip > # Make a local copy of HoH > my $ref = $fileSizes; > > # remove a hash via key c > delete $ref->{'c'}; snip The refs $ref and $fileSizes point to the same hash. What you need to do is make a copy. There are several way

Re: Making variables private

2008-03-06 Thread yitzle
I don't know much about how Perl deals with this stuff, but what you've done is made a copy of the pointer/reference. Both variables are referencing the same memory/hash. What you want to do is copy the hash, not copy the reference to it. I /think/ this ought to work: my %hash = %{$fileSize}; __CO