Jrchak has asked for the wisdom of the Perl Monks concerning the following question:
Here is my regex to extract the data I want and some sample use of the code:<p><b>Area:</b> <br><i>total:</i> 9,629,091 sq km <br><i>land:</i> 9,158,960 sq km <br><i>water:</i> 470,131 sq km <p><b>Area - comparative:</b> about one-half the size of Russia; about three-tenths the size of Afri +ca; about one-half the size of South America (or slightly larger than + Brazil); slightly larger than China; about two and one-half times th +e size of Western Europe <p><b>Land boundaries:</b> <br><i>total:</i> 12,248 km <br><i>border countries:</i> Canada 8,893 km (including 2,477 km with Alaska), Cuba 29 km (US Naval + Base at Guantanamo Bay), Mexico 3,326 km <br><i>note:</i> Guantanamo Naval Base is leased by the US and thus remains part of Cub +a <p><b>Coastline:</b> 19,924 km
This will work and will copy "9,629,091 sq km" to $Area_total. My problem is that after having that extracted I can seem to get similar data like the total under Land Boundries. I try the same code and It fails, I also tried to incorperate thesub extractData { ($start, $end, $rawData) = @_; if ($rawData =~ /$start\s*(.+?)\s*$end/) { $content = $1; } else { print "no location given, jackass."; $content = 0; } return $content; } $Start = "<i>total:</i>"; $End = "<br>"; $Area_total = extractData($Start, $End, $rawHtml);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting similar data from html
by ichimunki (Priest) on Jan 24, 2001 at 07:56 UTC | |
by Jrchak (Initiate) on Jan 24, 2001 at 08:45 UTC | |
by ichimunki (Priest) on Jan 24, 2001 at 19:57 UTC | |
|
Re: Extracting similar data from html
by MeowChow (Vicar) on Jan 24, 2001 at 12:07 UTC | |
|
Re: Extracting similar data from html
by dkubb (Deacon) on Jan 24, 2001 at 14:19 UTC |