how to NOT quote constants in hash keys
From: Martin Adler (orzacha_at_yahoo.de)
Date: 06/28/04
- Next message: Clint Olsen: "Does Perl combine multiple REs into a single automaton?"
- Previous message: Derf: "Re: grabbing array vlaues in a loop where array is redefined"
- Next in thread: Tore Aursand: "Re: how to NOT quote constants in hash keys"
- Reply: Tore Aursand: "Re: how to NOT quote constants in hash keys"
- Reply: Paul Lalli: "Re: how to NOT quote constants in hash keys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Jun 2004 09:59:53 -0700
What can I "use" to make the following program work as I want it to?
#!/usr/bin/perl -w
use strict;
use constant N => 17 ;
my %x ;
$x{N} = 25 ; # who wants to write $x{(N)} = 25 all the time?
print keys %x ;
The output is "N", so Perl apparently interprets $x{N} as $x{"N"}.
But how can I tell it to interpret constants as their (constant)
value?
I want Perl to interpret $x{N} as $x{17}.
One of the goals of perl is "to make easy tasks easy and difficult
tasks possible". It seems to me that it is POSSIBLE to use constants
as hash keys (e.g.: $x{ (N) }), but it does not look EASY.
Or what else should I do?
- Next message: Clint Olsen: "Does Perl combine multiple REs into a single automaton?"
- Previous message: Derf: "Re: grabbing array vlaues in a loop where array is redefined"
- Next in thread: Tore Aursand: "Re: how to NOT quote constants in hash keys"
- Reply: Tore Aursand: "Re: how to NOT quote constants in hash keys"
- Reply: Paul Lalli: "Re: how to NOT quote constants in hash keys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]