Skip Menu |

This queue is for tickets about the HTML-Tree CPAN distribution.

Report information
The Basics
Id: 84479
Status: rejected
Priority: 0/
Queue: HTML-Tree

People
Owner: Nobody in particular
Requestors: jeanniesyusir [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: look_down() not returning list context reliably
Date: Sat, 06 Apr 2013 18:06:32 -0500
To: bug-html-tree [...] rt.cpan.org
From: Bozonius <jeanniesyusir [...] gmail.com>
look_down() is supposed to return a list or scalar depending on context. The attached proof demonstrates that this does not seem to happen reliably. I have not figured out a reliable workaround; in one case, I was able to change the code to a for loop and that seems to have forced the list context, but that does not always work. I do have quite a bit invested in this module, which is turning my project into a virtual doorstopper. Please note that the modified version of the module sometimes does not print the expected context. My script does not seem to cause this, but I have other scripts where the return value from wantarray inside look_down does, in fact, return false when it is clearly a list context. Perhaps you may encounter this at some point, which would indicate an issue with the interpreter.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

I'm fairly sure this is just bugs in your code. I don't think you're working with the element you think you're working with. Try using the dump method. For example, $tr->dump in your example would print <tr> @0.1.4.0.0.1.0.0 <td colspan="2"> @0.1.4.0.0.1.0.0.0 <div class="xbtn" onclick="google.promos&amp;&amp;google.promos.toast&amp;&amp; google.promos.toast.cpc()" style="float:right"> @0.1.4.0.0.1.0.0.0.0 "" There's only 1 <td> element in that row, which is why you only get one. (It has colspan="2", but HTML::Element is not a table parser.) I suspect the issue here is that you meant $form->look_down(_tag => 'table') but wrote $center->look_down(_tag => 'table') instead. (You find a $form tag, but never use it for anything.) You can also dump the whole tree, and then compare that to the dump of the element you're working with. The "@0.1.4.0.0.1.0.0" part of the dump is the element's address, which uniquely identifies each element based on its position in the tree. You can use that to find a particular element in the whole-tree dump. I've never seen wantarray return the wrong context, but if it did, that'd be a bug in Perl, not HTML::Element. I suspect you've just misunderstood Perl's context rules.
Subject: Re: [rt.cpan.org #84479] look_down() not returning list context reliably
Date: Wed, 17 Apr 2013 04:36:52 -0500
To: bug-HTML-Tree [...] rt.cpan.org
From: Jeannie S Yusir <jeanniesyusir [...] gmail.com>
Sorry, I meant to get back to you on this, but then there were several other fires here. Yes, you are completely correct. The problem was that I was trying to debug one problem (where I am pretty sure it really was a wantarray problem) and in trying to break down the problem got caught up in a different issue. The proof was not of the problem I originally started investigating. If I am able to reproduce the actual issue I wanted to report, I will send it along under a different ticket. Sorry for the bother. J On Sunday, April 07, 2013 01:09:11 AM you wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=84479 > > > I'm fairly sure this is just bugs in your code. I don't think you're > working with the element you think you're working with. Try using
the dump Show quoted text
> method. For example, $tr->dump in your example would print > > <tr> @0.1.4.0.0.1.0.0 > <td colspan="2"> @0.1.4.0.0.1.0.0.0 > <div class="xbtn" >
onclick="google.promos&amp;&amp;google.promos.toast&amp;&amp; Show quoted text
> google.promos.toast.cpc()" style="float:right"> @0.1.4.0.0.1.0.0.0.0
"" Show quoted text
> > There's only 1 <td> element in that row, which is why you only get
one. (It Show quoted text
> has colspan="2", but HTML::Element is not a table parser.) > > I suspect the issue here is that you meant $form->look_down(_tag
=> 'table') Show quoted text
> but wrote $center->look_down(_tag => 'table') instead. (You find a
$form Show quoted text
> tag, but never use it for anything.) > > You can also dump the whole tree, and then compare that to the
dump of the Show quoted text
> element you're working with. The "@0.1.4.0.0.1.0.0" part of the
dump is Show quoted text
> the element's address, which uniquely identifies each element
based on its Show quoted text
> position in the tree. You can use that to find a particular element in
the Show quoted text
> whole-tree dump. > > I've never seen wantarray return the wrong context, but if it did,
that'd be Show quoted text
> a bug in Perl, not HTML::Element. I suspect you've just
misunderstood Show quoted text
> Perl's context rules.
Subject: Re: [rt.cpan.org #84479] look_down() not returning list context reliably
Date: Sun, 14 Jul 2013 00:22:27 -0500
To: bug-HTML-Tree [...] rt.cpan.org
From: Jeannie S Yusir <jeanniesyusir [...] gmail.com>
On 04/07/2013 12:09 AM, Christopher J. Madsen via RT wrote: Show quoted text
> I suspect the issue here is that you meant $form->look_down(_tag => 'table') but wrote $center->look_down(_tag => 'table') instead. (You find a $form tag, but never use it for anything.)
Yes, I meant to call from the $form tag -- the problem is that there are two different tables in the document, not one. My bad. Back when I was debugging this, I thought there was only one. Show quoted text
> I've never seen wantarray return the wrong context, but if it did, that'd be a bug in Perl, not HTML::Element. I suspect you've just misunderstood Perl's context rules.
No, not at all. I totally get the context rules. The problem was, as mentioned above, there being two tables one of which I was not aware of. I will be more alert for duplicate elements in these contexts in the future. Thank you for your help. J