- 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
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:
>>
>>
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
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
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
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};
>
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