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} .
"\n");
print("Comparison 1: " . (SOME_CONSTANT eq $index) . "\n");
print("Comparison 2: " . ($hash{SOME_CONSTANT} ne $hash{$index}) . "\n");
$ perl ./hash-test.pl
The value is: value 1/value 2
Comparison 1: 1
Comparison 2: 1
???
So, what behavior exactly is it that you consider weird? What output had
you expected?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/