Hi monks,

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>

I tried to use below perl code to get the value, but didn't work out

my $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; }
Thanks

In reply to Table data by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.