A UserAgent will not handle cookies unless you tell it to, by assigning it an empty cookie jar:
$Ua->cookie_jar( {} );
Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.
Quick
- ($a, $b....) = unpack("A2A7...", $packed)
- push( array, list )
Tuesday, December 21, 2010
Perl HTML parsing - text nodes
As far as I can see, text nodes are accessed via the HTML::Element content_list method: this returns a list of child nodes. The members of this list are either HTML::Element object references, or strings of text.
HTML::Element also has as_text which returns all text under a node.
HTML::Element also has as_text which returns all text under a node.
Monday, December 20, 2010
Perl HTML parsing - look_down
look_down is a method of HTML::Element.
If an attr_value parameter is a qr() then it is supposed to do a regexp match for you, but I couldn't make this work. I had to use
$link = $root->look_down( _tag => 'a', sub { $_[0]->attr('title') =~ qr(^Cool); } );
instead of
$link = $root->look_down( _tag => 'a', title => qr(^Cool) );
If an attr_value parameter is a qr() then it is supposed to do a regexp match for you, but I couldn't make this work. I had to use
$link = $root->look_down( _tag => 'a', sub { $_[0]->attr('title') =~ qr(^Cool); } );
instead of
$link = $root->look_down( _tag => 'a', title => qr(^Cool) );
Thursday, December 16, 2010
Perl bitwise operators
Beware - Perl is not SQL, and == has higher precedence than &, so if you have this
if ($flags & 3 == 3)
you are not performing a useful test. Parenthesise
if ( ($flags & 3) == 3)
if ($flags & 3 == 3)
you are not performing a useful test. Parenthesise
if ( ($flags & 3) == 3)
Subscribe to:
Comments (Atom)