How to create submenu HTML?

I have an HTML file. I would like to extract certain data/lines/strings and create a hash array using Perl. I have written Perl scripts using regular expressions earlier, but how do I use HTML Perl modules?

  • These are the lines in the file: <td><b>SCORE</b></td><td>WEIGHT</td><td>GOAL</td><td class="alfsrt">NAME</td></tr><tr> <td class="s5 rt"> 59.37</td> <td class="wht">1     </td> <td class="wht">100   </td> <td><a name="tag_ddr3ctrl_top.T0::ddr3ctrl_coverage::inputs"></a> <a href="grp0.html" >ddr3ctrl_top.T0::ddr3ctrl_coverage::inputs</a></td> </tr><tr> <td class="s7 rt"> 78.32</td> <td class="wht">1     </td> <td class="wht">100   </td> <td><a name="tag_ddr3ctrl_top.T0::ddr3ctrl_coverage::outputs"></a> <a href="grp1.html" >ddr3ctrl_top.T0::ddr3ctrl_coverage::outputs</a></td> I want to extract the following by parsing the file: 1) s5, grp0.html, inputs 2) s7, grp1.html, outputs

  • Answer:

    The most reliable way I know of is to have https://metacpan.org/pod/HTML::TreeBuilder parse your file, which will then give you an object containing an HTML Tree, which you can navigate with the methods documented for https://metacpan.org/pod/HTML::Element. It will take a bit to learn the API and how to use it effectively, but https://metacpan.org/pod/distribution/HTML-Tree/lib/HTML/Tree/AboutTrees.pod and https://metacpan.org/pod/distribution/HTML-Tree/lib/HTML/Tree/Scanning.pod will provide some guidance.

Christian Walde at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.