Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: one hash value (array) into another

by calin (Deacon)
on Jan 20, 2004 at 19:26 UTC ( #322679=note: print w/replies, xml ) Need Help??


in reply to one hash value (array) into another

If you want different arrays, with the same scalar things inside, you can do:

use Data::Dumper; $h{a} = [qw/x y z/]; $h{b} = &{sub {\@_}}(@{$h{a}}); $h{a}->[0] = 'new_x_is_shared'; push @{$h{a}}, 'pusher_is_not_shared'; print Dumper $h{a}; print Dumper $h{b};

with the output:

$VAR1 = [ 'new_x_is_shared', 'y', 'z', 'pusher_is_not_shared' ]; $VAR1 = [ 'new_x_is_shared', 'y', 'z' ];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://322679]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2021-08-05 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (44 votes). Check out past polls.

    Notices?