jms53 has asked for the wisdom of the Perl Monks concerning the following question:
<span> Author_name </span> __filler__ <ul> <li> book 1 by Author_name </li> <li> book 2 by Author_name </li> <ul> <span> New_Author </span> __filler__ <ul>.....
By using the look_down method, I was able to create a list of authors, and a list of books. What I have not been able to do, is assign a book to a given author, in order to sort for example by number of published books.
I thought of doing something as follows:
my %publications = $tree->look_down( _tag => 'span'); open my $fh , "<", $tree->as_HTML; while (<$fh>) { my $author; next unless ($_ =~ /(?:span|li)/; $_ =~ /span/ ? $author =~ /\>(.+)\<\/span/ : push @publications{$aut +hor}, /li\>(.+)\<\/li/; }
Maybe I'm barking up the wrong tree? Thank you for the input!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Possible to treat an HTML::TreeBuilder object as a filehandle? (perldoc -f open)
by Anonymous Monk on Feb 11, 2014 at 09:16 UTC | |
by jms53 (Monk) on Feb 11, 2014 at 09:42 UTC | |
by Anonymous Monk on Feb 11, 2014 at 10:16 UTC | |
|
Re: Possible to treat an HTML::TreeBuilder object as a filehandle?
by Util (Priest) on Feb 13, 2014 at 21:40 UTC |