in reply to hashes,references and subroutines

diarmuid You're nearly there. Try to understand that a hash-of-a-hash is really a hash-of-hashreferences.

If you leave out the referencing in line 2, you are fine (alternatively, do a double dereferencing in the sub).

Hope this helps,

jeroen
"We are not alone"(FZ)
Update: Forgot some ObDocLinks: perlref, perlreftut,perldsc and perllol
Use CODE tags around your code:
<CODE>
#my perlcode may contain any character like [] </CODE>
Read Writeup Formatting Tips

Replies are listed 'Best First'.
Re: Re: hashes,references and subroutines
by diarmuid (Beadle) on Apr 19, 2001 at 16:59 UTC
    OK, I'm still not sure what's going on.
    I ran

    foreach my $key (sort keys %clocks){ print_clock_assertions({ $clocks{$key} }); #line 32 } sub print_clock_assertions { my($hashref)=$_[0]; print STDOUT "ref 1 :$hashref->{'speed'}\n"; #line 44 }
    and got loads of
    Odd number of elements in hash assignment at parse_timing_info.pl line + 32. Use of uninitialized value in concatenation (.) at parse_timing_info.p +l line 44. ref 1 :
    does $hashref contain the has reference when I do this?

    PS Why how do stop the square bracket being removed?

    Edit: chipmunk 2001-04-19

      You have to remove the {} in line 32.

      PS: Put your code in <code>tags.