Subject: | HTML::Element bug? |
Date: | Mon, 21 Aug 2006 10:59:53 +0400 |
To: | petek [...] cpan.org |
From: | "Andrew Suhachov" <suhachov [...] gmail.com> |
Hello.
I've found that following code doesn't work:
$tree->look_down( _tag=>'tr', sub
{
my $tr = shift;
$tr->look_down( _tag=>'td', _parent=>$tr) ? 1 : 0;
} )
(i.e. I want to find all TD that are direct children of TR.).
This doesn't work, because of the following code in HTML::Element package:
or (
$c->[2] eq 'Regexp'
? $val !~ $c->[1]
: ( ref $val ne $c->[2]
# have unequal ref values => fail
or lc($val) ne $c->[1]
# have unequal lc string values => fail
))
Passed reference is compared with LOWERCASED sample. If I pass:
_parent => lc $tr
this doesn't work too, because "ref $val ne $c->[2]" fails.
Of course, I can write:
"sub {$_[0]->_parent eq $tr}" instead of "_parent=>$tr" but I
think this is ugly and
slow :(
So I can suggest a patch:
or lc($val) ne $c->[1]
replace with
or lc($val) ne lc($c->[1])
I did it in my local copy and this works fine.
--
Best regards, Andrew.