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;
>     print $new_hash->{second};
> }
 
more concise, probably faster:  
 
C:[EMAIL PROTECTED]>perl -we "use strict;   our $hashref = { first => 1, second => 2 };
&mysub;   print qq(main: $hashref->{second} \n);
sub mysub { my $hr = { %$hashref }; print qq(mysub a: $hr->{second} \n);
$hr->{second} = 10; print qq(mysub b: $hr->{second} \n) }"
mysub a: 2
mysub b: 10
main: 2
 
hth -- bill walters  
 
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to