R
Rg
Saluton,
Please, take a look at the following Perl program:
-----------------------
#!/usr/bin/perl
use strict;
my $hash_ref = {
List => ()
};
$hash_ref->{List}[0]->{Something} = "Boo";
$hash_ref->{List}[1]->{Something_else} = "Not boo";
print "Something is $hash_ref->{List}[0]{Something}\n";
print "Something else is $hash_ref->{List}[1]{Something_else}\n";
-----------------------
The output for this program is
"Something is Boo
Something else is Not boo"
I wonder why. How comes Perl treat $hash_ref->{List}[0] both as a hash
reference and a hash? Am I missing something here? Is there "undefined
behavior" involved?
Please, take a look at the following Perl program:
-----------------------
#!/usr/bin/perl
use strict;
my $hash_ref = {
List => ()
};
$hash_ref->{List}[0]->{Something} = "Boo";
$hash_ref->{List}[1]->{Something_else} = "Not boo";
print "Something is $hash_ref->{List}[0]{Something}\n";
print "Something else is $hash_ref->{List}[1]{Something_else}\n";
-----------------------
The output for this program is
"Something is Boo
Something else is Not boo"
I wonder why. How comes Perl treat $hash_ref->{List}[0] both as a hash
reference and a hash? Am I missing something here? Is there "undefined
behavior" involved?