Hi,
I have an html file and I have to extract information from its table. I am new to perl but I would give my approach below so I could get some help..
In the html file the table is like for example
a 1
b 2
c 3
d 4
then there are two columsn and 4 rows.
that means the html file will have one tag <table> and </table>
and four <tr> and </tr> tags and two <td> and </td> tags if i am right.
Now if I have t o extract whole second column of the table and the elements in a text file separated by newline.
To start with first i will open the file like....
open (HTMLFILE,"webpage.html") or die "Could not open the file";
then I will start reading the file...
while(<HTMLFILE>)
{
$line = <HTMLFILE>;
#Dont know if its right
# Here I am trying to set the current line to a variable
if($line=~m/<table>)
#if the current line is equal to a particular expression like <table>
{
#then send the element to the text file
}
}
I am very much confused on how to get the second column. Also what is the way to write to the text file each time without overwriting. I cannot use sed or awk.
Please help me!
thanks in advance!!!