Axel R. wrote:
>[...]
> but if I display the dump of the element :
>
> print "racine :".$racine->dump."\n";
> if ($racine->content->[1]->content->[0] == undef) {...
>
> It works very well... but it display the $racine->dump before the word "racine"
> like that : [...]
First off, dump() doesn't /return/ things, it prints things. This is
in the docs. So instead use:
print "racine:\n";
$racine->dump;
print "\n";
Second off, you don't test "VALUE == undef" to test definedness. Read
the entry on defined() in perldoc. (Also understand that the '=='
operator compares numeric values, and consider what the numeric value
of undef is, and from that see what "VALUE == undef" actually does.)
> I try to acces to the content of an element like that :
> $racine is my element and I test to know if the
> $racine->content->[1]->content->[0] == undef
> exist...
>
> But i've got a nice :"Can't use an undefined value as an ARRAY reference at
> BusPop.pm line 60."
Okay, lessee, $racine is
0.1.1.0.0.0.0.0.2
and so $racine->content->[1]->content->[0] would be
0.1.1.0.0.0.0.0.2.1.0
and I do notice there's a
0.1.1.0.0.0.0.0.2.1.0
in the tree. So I don't see why this is failing.
Now, you have not tried to figure out /which/ value is not an arrayref
in this line:
$content->[1]->content->[0]
Try:
my $x1 = $racine->content;
print "x1 is $x1\n";
my $x2 = $x1->[1]->content;
print "x2 is $x2\n";
# then...
if( defined($x2->[0]) ) {
...
}
Note, for future reference, that I've provided a way to get nodes at
given points in the tree. This is in the documentation, under the
"address" method:
if(defined($racine->address( $racine->address() . ".0.1"))) {
..
}
Maybe I should tweak that so that one could do "relative addressing",
with something like $node->address('.0.1') or something, where the
leading dot means "follow indexes starting from this element, not from
the root". Yes, I think I'll add that to the next version.
--
Sean M. Burke [EMAIL PROTECTED] http://www.spinn.net/~sburke/