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 ways to do this. The easiest I
can think of is to use a serialization library to serialize the data
structure and then reinstate it:
#!/usr/bin/perl
use strict;
use warnings;
use Storable qw<freeze thaw>;
use Data::Dumper;
my $fileSize = {
a => { name => 'small', size => 50 },
b => { name => 'medium', size => 75 },
c => { name => 'large', size => 100 }
};
my $copy = thaw(freeze($fileSize));
delete $copy->{c};
print Dumper($fileSize, $copy);
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/