note
bart
Your problem is that you're mixing up hashes (%hash) with hash references (<c>{ key => value }</c>) -- note the braces.
<p>Replace the braces with parens and it should work:
<c>
my %hash = ('perl' => 1 , 'C' => 0) ;
</c>
This produces a flat list, not a hashref, which is exactly what assignment to a hash wants.
<p>Alternatively you could use a hashref (= a scalar pointing to a hash) everywhere:
<c>
my $hash = {'perl' => 1 , 'C' => 0} ;
foreach my $key(sort keys %$hash)
{
print "$key : $hash->{$key} \n" ;
}
</c>
1036580
1036580