vishwasu89 has asked for the wisdom of the Perl Monks concerning the following question:

I have a html file. I would like to extract certain data/lines/strings and create a hash array using perl. I have written perl scripts using regex earlier but how to 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">N +AME</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></t +d> </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

Replies are listed 'Best First'.
Re: Using HTML Modules to parse a file and extract relevant data?
by alexbyk (Novice) on Apr 26, 2014 at 22:55 UTC
    I've made a working example for you. Chek it out: https://gist.github.com/alexbyk/11333279

    You can rewrite it for you own needs. See:
    https://metacpan.org/pod/Mojo::DOM::CSS#SELECTORS
    https://metacpan.org/pod/Mojo::DOM

      ++ It would probably be better, in the interests of future continuity, to put the code here and enclose it in <readmore/> tags if you feel it’s longish for a post. I love gists too but splitting the narrative, as it were, doesn’t work online for long.

        Thanks for the advise. Got it)

      Thanks!

Re: Using HTML Modules to parse a file and extract relevant data?
by Anonymous Monk on Apr 26, 2014 at 22:34 UTC