diarmuid has asked for the wisdom of the Perl Monks concerning the following question:
I've started messing around with references today and I have a few questions.
I have a hash of a hash %clocks (eg $clock{<name>}{'speed'})
Now I want to read the outer hash in a subroutine. I was reading on
references and I think that's what I should use, but I'm not sure of
the syntax.
eg
foreach my $key (sort keys %clocks){ print_clock_assertions(\{ $clocks{'$key'} }); } sub print_clock_assertions { my($hashref)=$_[0]; print STDOUT "ref 1 :$hashref->{'speed'}\n"; }
This doesnt work so if you know what I'm at could you point me in the right direction?
Diarmuid
Edit: chipmunk 2001-04-19
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hashes,references and subroutines
by jeroenes (Priest) on Apr 19, 2001 at 16:46 UTC | |
by diarmuid (Beadle) on Apr 19, 2001 at 16:59 UTC | |
by busunsl (Vicar) on Apr 19, 2001 at 17:07 UTC | |
|
Re: hashes,references and subroutines
by Anonymous Monk on Apr 19, 2001 at 17:07 UTC | |
|
Re: hashes,references and subroutines
by mr.nick (Chaplain) on Apr 19, 2001 at 16:46 UTC | |
|
Re: hashes,references and subroutines
by diarmuid (Beadle) on Apr 19, 2001 at 18:40 UTC |