tcf03 has asked for the wisdom of the Perl Monks concerning the following question:
when I change $$ranimals{'duck'} to shouldnt $animals{'duck'} still be "goose"? Or am I just greatly misunderstanding what this is doing?#!/usr/bin/perl -w use strict; my %animals=( 'cow' => "bessie", 'horse' => "ed", 'duck' => "goose", 'dog' => "rexx" ); print "my animals\n"; print_hash(); my $ranimals=\%animals; $$ranimals{'duck'} = "franklin"; print "\nmy referenced animals\n"; print_hash(); sub print_hash { for ( sort keys(%animals) ) { print "$_ = $animals{$_}\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: references changing a hash value
by davorg (Chancellor) on Apr 26, 2005 at 15:21 UTC | |
|
Re: references changing a hash value
by tlm (Prior) on Apr 26, 2005 at 13:53 UTC | |
|
Re: references changing a hash value
by splinky (Hermit) on Apr 26, 2005 at 14:01 UTC |