On Fri, Apr 4, 2008 at 11:42 PM,  <[EMAIL PROTECTED]> wrote:
> use constant PART_NUMBER            => 'P/N';
>
>  print PART_NUMBER;
>
>  The above prints, "P/N", as I would expect.  Later in the script I
>  want to access a hash value using the constant like this:
>  my $part = $parts{ $key }{ PART_NUMBER }; <- this doesn't work, but

because the hash think "PART_NUMBER" is a key name instead of a constant.
to avoid this confusion, add a "+" before the constant,

my $part = $parts{ $key }{ +PART_NUMBER };

Good luck!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to