i'm hoping that someone can explain what i'm seeing.
run a script with the following code
my %args;
$args{'expr'} = \['booya' 'kada'];
then perform 'x \%args'...you'll see this:
DB<2> x \%args
0 HASH(0x1cb3778)
'expr' => REF(0x1a35d54)
-> ARRAY(0x1ca0124) (WHY AN ARROW?)
0 'booya'
1 'kada'
then run the followin in a script:
my %args;
my @ary;
@ary = ['booya', 'kada'];
$args{'expr'} = \@ary;
in this case 'x \%args' produces:
DB<3> x \%args
0 HASH(0x1cb3778)
'expr' => ARRAY(0x1cb3844)
0 ARRAY(0x1cea068) (WHY A ZERO?)
0 'booya'
1 'kada'
so my question is this: what to the ARROW & ZERO signify and what is the difference. i'm guessing its related to anonymity, but i don't know and i believe there is a gem of knowledge here i don't want to lose.
i suppose a second question is this: where could i have found this answer myself - any documentation that explains debugger command outputs (in detail).
thanks in advance, nebbish
$VAR1 = {
'expr' => \[
'booya',
'kada'
]
};
$VAR1 = {
'expr' => [
[
'booya',
'kada'
]
]
};
I thing you are confused about the way array references are created in perl. Probably, you would like to use...
my %args;
$args{'expr'} = ['booya' 'kada']; # no \ required here
or
my %args;
my @ary;
@ary = ('booya', 'kada'); # use () instead of []
$args{'expr'} = \@ary;
to create
$VAR1 = {
'expr' => [
'booya',
'kada'
]
};
In the first dump you gave, the container that held a reference to ['booya', 'kada'] had no interesting type of its own, therefore its stringification was REF (ref-to-a-ref). In the second case, you had an array container, and the first element of the array was a reference to ['booya', 'kada']. The second case, with the 0, should be clear: the 0th element of the array pointed to by \@ary is the anonymous array.
In the second case, there is no index, there's just a straight reference. That is signified by an arrow.
I think this is the kind of thing you either don't worry about, or deduce, or read the source for. :-)
perlmonks.org content © perlmonks.org and gaal, nebbish, salva
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03