in reply to Hash of refs to refs
Update: after reading jeffa's reply... if you wanted a hash slice, then my answer is a bit off...
That probably won't do what you thought it would... Try printing the contents of the has using Data::Dumper, and I think you will see:
use Data::Dumper; my %sample = ( [ 1, 2, 3, 4 ] => [ 5, 6, 7, 8 ] ); print Dumper( \%sample ); ==output== $VAR1 = { 'ARRAY(0x13c864)' => [ 5, 6, 7, 8 ] };
As you can see, hash keys are stringified. it does NOT hold the actual ref to an array...
The reason why your foreach loop works is because when you call keys(), you get the string values which are used as the hash keys... but you can't dereference them because they are just strings representing the arrayref's location in memory ( I think that's wht those hex numbers mean )
Anyway, the point is that in your code, $key is a string, not an arrayref. If you want to get to the array ref you have to do a bit more work
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Hash of refs to refs
by rje (Deacon) on Dec 01, 2001 at 02:18 UTC | |
by jeffa (Bishop) on Dec 01, 2001 at 20:24 UTC |