D
david
Hi all,
Is there an option to create a constant hash ?
I tried two snippets
This does not compile:
use strict;
use warnings;
my %hash =(1=>2);
use constant A=>%hash;
print A{1},"\n";
syntax error at a.pl line 6, near "A{"
Execution of a.pl aborted due to compilation errors.
and the following does not do the work:
use strict;
use warnings;
my %hash =(1=>2);
use constant A=>\%hash;
print A->{1},"\n";
print A->{2},"\n";
print "why do i print this ?\n"
2
why do i print this ?
I thought afterwards, that the second snippet has no chance to work.
The hash address remains constant even the values changes :-(.
Has anyone another idea ?
Thanks,
David
Is there an option to create a constant hash ?
I tried two snippets
This does not compile:
use strict;
use warnings;
my %hash =(1=>2);
use constant A=>%hash;
print A{1},"\n";
syntax error at a.pl line 5, near "A{"perl -w a.pl
syntax error at a.pl line 6, near "A{"
Execution of a.pl aborted due to compilation errors.
and the following does not do the work:
use strict;
use warnings;
my %hash =(1=>2);
use constant A=>\%hash;
print A->{1},"\n";
print A->{2},"\n";
print "why do i print this ?\n"
Use of uninitialized value in print at a.pl line 6.perl -w a.pl
2
why do i print this ?
I thought afterwards, that the second snippet has no chance to work.
The hash address remains constant even the values changes :-(.
Has anyone another idea ?
Thanks,
David