Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: help with references

by tobyink (Abbot)
on May 04, 2013 at 19:22 UTC ( #1032075=note: print w/replies, xml ) Need Help??


in reply to help with references

$h{2} isn't a reference to $h{1}. $h{2} is a reference to the same array that $h{1} refers to.

I think you probably want:

for my $i ( 1 .. 2 ) { my @new = @a; # copy of @a $h{"$i"} = \@new; # reference the copy }

Or (more concise way of saying the same thing)...

for my $i ( 1 .. 2 ) { $h{"$i"} = [@a]; }
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^2: help with references
by dw_perlmonks (Novice) on May 04, 2013 at 20:09 UTC
    tobyink, thanks for replying. But what I was expecting is different. I've updated my post with more info.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032075]
help
Chatterbox?
[Corion]: ambrus: AnyEvent(::HTTP) doesn't integrate well with Prima, that's my main problem
[Corion]: There is a weirdo shim because there is a POE integration for Prima, and if you use that, you can use the POE adapter of AnyEvent. What I'd want is something transport agnostic that parses HTTP or produces HTTP output, so that the communication with ...
[Corion]: ... the socket is done by my code. Ideally that module would not be based on callbacks ;)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2016-12-07 15:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (130 votes). Check out past polls.