Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
How to get table data in an array. Html page code is given below
<html> <title>Hprices</title> <form style="margin: 0px; padding: 0px;" id="selectHistoricalFormId" action="" method="post"> <fieldset><legend>Search Historical prices</legend> <table style="margin-top: 4px;"> <tbody> <tr> <td><label>From: </label></td> <td><input class="hasDatepicker embed" id="Fro +mDate" type="text"><img title="..." alt="..." src="historical_prices_files/calendar.gif" class="ui-datepicker-trigger"></td> <td><label>To: </label></td> <td><input class="hasDatepicker embed" id="ToD +ate" type="text"><img title="..." alt="..." src="historical_prices_files/calendar.gif" class="ui-datepicker-trigger"></td> <td><input class="searchButton" onclick="histo +rical.load();return false;" value="Search" type="button"></td> <td> <div class="linkIcon_xls" id="exportExcel">&nb +sp;</div> </td> </tr> </tbody> </table> </fieldset> </form> <div id="historicalOutput"><table id="historicalTable" class="tablesorter" border="0" cellpadding="0" cellspacing="0"> <thead> <tr> <th class="header headerSortUp" title="Date">Date</th> <th class="header" title="High price">High price</th> <th class="header" title="Low price">Low price</th> <th class="header" title="Closing price">Closing price</th> <th class="header" title="Average price">Average price</th> <th class="header" title="Total volume">Total volume</th> <th class="header" title="Turnover">Turnover</th> </tr> </thead> <tbody> <tr class="odd" id="historicalTable-"> <td>2010-08-03</td> <td>294.77</td> <td>294.77</td> <td>294.77</td> <td></td> <td>1</td> <td>13,000</td> </tr> <tr class="even" id="historicalTable-"> <td>2010-08-02</td> <td>294.77</td> <td>294.77</td> <td>294.77</td> <td></td> <td>1</td> <td>143,801</td> </tr><tr class="odd" id="historicalTable-"> <td>2010-07-30</td> <td>294.77</td> <td>294.77</td> <td>294.77</td> <td></td> <td>1</td> <td>219,800</td> </tr><tr class="even" id="historicalTable-"> <td>2010-07-29</td> <td>294.77</td> <td>294.77</td> <td>294.77</td> <td></td> <td>1</td> <td>70,800</td> </tr><tr class="odd" id="historicalTable-"> <td>2010-07-28</td> <td>302.14</td> <td>302.14</td> <td>302.14</td> <td></td> <td>1</td> <td>1,924,345</td> </tr><tr class="even" id="historicalTable-"> <td>2010-07-27</td> <td>302.14</td> <td>302.14</td> <td>302.14</td> <td></td> <td>1</td> <td>54,325</td> </tr><tr class="odd" id="historicalTable-"> <td>2010-07-26</td> <td>302.14</td> <td>302.14</td> <td>302.14</td> <td></td> <td>1</td> <td>67,855</td> </tr></tbody> </table></div> </html>
Thanksmy $body_part=""; while(<DATA>) { chomp($_); $body_part .= $_; } $body_part =~s/^.*?<div id=\"historicalOutput\" .*?>.*<tbody>(.*?)<\/t +body>/$1/sigm; my @data = $body_part =~ m/<tr>(.*?)<\/tr>/sigm; my @consolidated_data=(); foreach my $newdata (@data) { @consolidated_data = $newdata =~ m/<td.*?>(.*?)<\/td>/sigm; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Table data
by jethro (Monsignor) on Oct 25, 2010 at 14:23 UTC | |
|
Re: Table data
by mojotoad (Monsignor) on Oct 26, 2010 at 02:15 UTC | |
|
Re: Table data
by locked_user sundialsvc4 (Abbot) on Oct 25, 2010 at 14:51 UTC | |
|
Re: Table data
by Monkomatic (Sexton) on Oct 26, 2010 at 01:31 UTC |