hash copy

2019-03-24 Thread Marcel Timmerman
Hi, I was wandering if the following is an assignment or a binding (or binding of the entries); my Hash $sleep-wait = { :s1(4.3), :s2(2.1), :s3(5.3), :s4(10.4), :s5(8.7),}; my Hash $sleep-left = $sleep-wait; I noticed that in the following piece of code the $sleep-wait hash entries were s

Re: hash copy

2019-03-24 Thread Brad Gilbert
You created a single Hash then assigned it to two variables. Also `clone` always does a shallow clone. So there will be two Hashes, but the values will still share the same scalar container. If you add a new key it won't be in the other Hash. my $a = { a => 1 }; my $b = $a.clone; $b =

Re: hash copy

2019-03-24 Thread yary
Brad Gilbert wrote: >Which shows that if you are dealing with a Hash it is probably better >to use a % variable. Indeed and coming from Perl 5 I find using the sigils % and @ for "does Associative" and "does Positional" maps better to that experience. > my %a = :s1(4.3), :s2(2.1), :s3(5.3); {s1 =

Re: hash copy

2019-03-24 Thread Marcel Timmerman
Hi Brad and Yari, Thanks very much for your in depth explanations. Regards, Marcel