in reply to How to dereference when hash key is referenece
#!/usr/local/bin/perl use strict; use warnings; my $array_ref = [1, 2, 5, 7, 4]; my %hash; $hash{join $;, @$array_ref} = 'ashok'; for my $as (keys %hash){ print join ',', split /$;/, $as; }
Prints:
1,2,5,7,4
as you wanted. This works by creating a string that contains the array values and uses the string as the hash key. The split pulls the key string back apart for printing.
This is very likely not a good solution to your actual problem however!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to dereference when hash key is referenece
by codeacrobat (Chaplain) on Apr 27, 2006 at 05:52 UTC | |
by GrandFather (Saint) on Apr 27, 2006 at 07:00 UTC |