Re: hash copy

2006-06-13 Thread Petr Vileta
- Original Message - From: "Charles K. Clarkson" <[EMAIL PROTECTED]> To: "'ActivePerl'" Sent: Tuesday, June 13, 2006 4:28 AM Subject: RE: hash copy Petr Vileta wrote: : I have public hash and in sub{} A public hash sounds like a really bad

RE: hash copy

2006-06-13 Thread Brian Raven
Charles K. Clarkson <> wrote: > Petr Vileta wrote: > >> I have public hash and in sub{} > > A public hash sounds like a really bad idea. Why not use a > lexically scoped hash and specifically pass it into the sub? > > >> Example with success but maybe is possible to write it better: >> >>

Re: hash copy

2006-06-12 Thread Bernie Cosell
On 10 Jun 2006 at 2:12, Petr Vileta wrote: > How to Perl compel to create copy of hash? > I have public hash and in sub{} I want to create local copy without > reference to original. In your sub, just do: my %localhash = %$publichash /bernie\ -- Bernie Cosell Fantasy Far

RE: hash copy

2006-06-12 Thread Charles K. Clarkson
Petr Vileta wrote: : I have public hash and in sub{} A public hash sounds like a really bad idea. Why not use a lexically scoped hash and specifically pass it into the sub? : Example with success but maybe is possible to write it better: : : our $hash; : $hash->{first} = 1; : $hash->{second

Re: hash copy

2006-06-12 Thread Williamawalters
hi petr --     In a message dated 6/12/2006 9:19:16 P.M. Eastern Standard Time, [EMAIL PROTECTED] writes:   > sub mysub {> my $new_hash;> $new_hash->{$_} = $hash->{$_} foreach (keys %{$hash}); # make local copy> print $new_hash->{second};> $new_hash->{second} = 10;> pr

Re: hash copy

2006-06-12 Thread $Bill Luebkert
Petr Vileta wrote: > How to Perl compel to create copy of hash? > I have public hash and in sub{} I want to create local copy without > reference to original. > > Example with not acceptable result: > > our $hash; > $hash->{first} = 1; > $hash->{second} = 2; > &mysub; > print $hash->{second}; >

hash copy

2006-06-12 Thread Petr Vileta
How to Perl compel to create copy of hash? I have public hash and in sub{} I want to create local copy without reference to original. Example with not acceptable result: our $hash; $hash->{first} = 1; $hash->{second} = 2; &mysub; print $hash->{second}; sub mysub { my $new_hash = $hash; # m