Fool on the Hill has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I would really like to be able to get a variable name from a reference so that I could do things like this:
Output#!/usr/bin/perl -w use strict; my %hash1=("A"=>1); my %hash2=("B"=>2); foreach my $hashref (\%hash1,\%hash2) { print "$hashref:",ref($hashref),":",(join ",",sort keys %{$hashref}) +,"\n";
But I would really like to display the name of the hash that is referenced like this:HASH(0x2002a3d0):HASH:A HASH(0x2002a418):HASH:B
Cheers.hash1:A hash2:B
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Getting a variable name from a reference
by MZSanford (Curate) on Mar 05, 2002 at 13:46 UTC | |
by tye (Sage) on Mar 05, 2002 at 14:55 UTC | |
by shotgunefx (Parson) on Mar 05, 2002 at 14:57 UTC | |
Re: Getting a variable name from a reference
by strat (Canon) on Mar 05, 2002 at 12:47 UTC | |
by erikharrison (Deacon) on Mar 05, 2002 at 13:31 UTC | |
Re: Getting a variable name from a reference
by Sweeper (Pilgrim) on Mar 05, 2002 at 21:57 UTC | |
by Fool on the Hill (Acolyte) on Mar 06, 2002 at 10:36 UTC | |
Re: Getting a variable name from a reference
by koolade (Pilgrim) on Mar 05, 2002 at 18:18 UTC |
Back to
Seekers of Perl Wisdom