Stanisław T. Findeisen wrote:
use constant {
SOME_CONSTANT => 'some value'
};
$hash{SOME_CONSTANT} = 'value 1';
Not weird at all, just works as documented.
So change to either:
$hash{ +SOME_CONSTANT } = 'value 1';
or:
$hash{ SOME_CONSTANT() } = 'value 1';
--
Ruud
--
To uns
On Fri, Mar 6, 2009 at 03:31, "Stanisław T. Findeisen"
wrote:
> Chas. Owens wrote:
>>
>> SOME_CONSTANT is being interpreted as the string "SOME_CONSTANT".
>
> Why is it so? This is crazy.
Because it is nicer to say $hash{key} than $hash{"key"} and Perl is
optimized for the common case. When you
From: "Stanisław T. Findeisen"
> Chas. Owens wrote:
> > SOME_CONSTANT is being interpreted as the string "SOME_CONSTANT".
>
> Why is it so? This is crazy.
Because most often you want it that way. Most often you do want the
$hash{BLAHBLAH} to mean $hash{'BLAHBLAH'} and not have to put qu
On Fri, Mar 06, 2009 at 09:31:44AM +0100, "Stanisław T. Findeisen" wrote:
> Chas. Owens wrote:
>> SOME_CONSTANT is being interpreted as the string "SOME_CONSTANT".
>
> Why is it so? This is crazy.
Were it not so, every time you created a sub with the same name as one
of your hash keys you would f
Chas. Owens wrote:
SOME_CONSTANT is being interpreted as the string "SOME_CONSTANT".
Why is it so? This is crazy.
This is one of the drawbacks to the constant pragma. Change the code
hash keys to one of these and it will work the way you want it to:
$hash{+SOME_CONSTANT} #unary plus
What
Stanisław T. Findeisen wrote:
#!/usr/bin/perl
use warnings;
use strict;
use constant {
SOME_CONSTANT => 'some value'
};
my $index = 'some value';
my %hash = ();
$hash{SOME_CONSTANT} = 'value 1';
$hash{$index} = 'value 2';
print("The value is: " . $hash{SOME_CONSTANT} . '/' . $hash{$index
On Thu, Mar 5, 2009 at 12:23, "Stanisław T. Findeisen"
wrote:
> #!/usr/bin/perl
>
> use warnings;
> use strict;
>
> use constant {
> SOME_CONSTANT => 'some value'
> };
>
snip
> print("The value is: " . $hash{SOME_CONSTANT} . '/' . $hash{$index} . "\n");
snip
SOME_CONSTANT is being interpreted
#!/usr/bin/perl
use warnings;
use strict;
use constant {
SOME_CONSTANT => 'some value'
};
my $index = 'some value';
my %hash = ();
$hash{SOME_CONSTANT} = 'value 1';
$hash{$index} = 'value 2';
print("The value is: " . $hash{SOME_CONSTANT} . '/' . $hash{$index} . "\n");
print("Comparison 1: