M
Martin Adler
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?
#!/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?