Gossamer Forum
Home : General : Perl Programming :

Extracting text from a page

Quote Reply
Extracting text from a page
As I loop through a text file I need to grab some text and assign it's value to a variable. How do I tell Perl to perform the following task:

<tr><td>Monday</td><td>1.500</td></tr>
<tr><td>Tuesday</td><td>2.870</td></tr>
<tr><td>Wednesday</td><td>3.600</td></tr>
<tr><td>Thursday</td><td>4.590</td></tr>
<tr><td>Friday</td><td>3.125</td></tr>

If line contains Wednesday, then go to the next <td> tag on that line and pull the number (or text) until the next closing </td> tag (or some other type of "delimiting" factor - maybe another word or bit of text).

this is what I'm thinking it should be ($Line being part of the foreach or while statement)

if ($Line =~ /wednesday/i) {
$Line ????? $1;
$wedRate = $1;
}

(where "print $wedRate" would result in 3.600)

It's the ???? that I'm not sure of - I've seen some examples but I did not understand them.

If anyone can give an example (and explain each step of what it's doing) I'd appreciate the help.
Subject Author Views Date
Thread Extracting text from a page Watts 5587 Jun 6, 2005, 9:32 AM
Thread Re: [Watts] Extracting text from a page
Andy 5463 Jun 7, 2005, 2:08 AM
Thread Re: [Andy] Extracting text from a page
Watts 5460 Jun 8, 2005, 9:07 AM
Thread Re: [Watts] Extracting text from a page
Andy 5456 Jun 8, 2005, 9:15 AM
Post Re: [Andy] Extracting text from a page
Watts 5430 Jun 8, 2005, 10:37 AM