Marcello has asked for the wisdom of the Perl Monks concerning the following question:
Only try 2 returns the desired result "OK" from hash1. Why not try 1 and try 3? Am I missing something?#!/usr/local/bin/perl -w use strict; use constant TESTVALUE => 1; my %hash1 = (TESTVALUE => "OK"); my %hash2 = (123 => TESTVALUE); my $hashValue; # Try 1 $hashValue = %hash1->{1}; # Try 2 $hashValue = %hash1->{TESTVALUE}; # Try 3 $hashValue = %hash1->{%hash2->{123}};
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Hash values and constants
by ihb (Deacon) on Jan 12, 2003 at 15:28 UTC | |
Re: Hash values and constants
by pfaut (Priest) on Jan 12, 2003 at 15:30 UTC | |
Re: Hash values and constants
by Wonko the sane (Deacon) on Jan 12, 2003 at 15:28 UTC | |
Re: Hash values and constants
by Aristotle (Chancellor) on Jan 12, 2003 at 16:23 UTC | |
by ihb (Deacon) on Jan 12, 2003 at 16:39 UTC | |
Re: Hash values and constants
by Marcello (Hermit) on Jan 12, 2003 at 15:51 UTC |