Using Perl to extract values from an HTML file
Hi. I have an HTML file that has a section devoted to countries, and I would like to make a hash of the country codes and the name of the country. Here is an example of the HTML code:
Thank you for your suggestions.
Are you familiar with CPAN? There are various HTML parsing
modules available for PERL.
Or if you are familiar with regular expressions in PERL,
you can always use regular expressions, such as by locating
a unique ID of the select statement, then marching through
the contained option elements.
I am a really big advocate of using industrial strength parsers for parsing HTML, but in this case, I think a simple Perl parser can do it. If you have some code that already extracts the part you've posted here, then it should be simple enought to split() on '</option><option value="', and then for each option section, split again on '">' to extract the key/value pairs.
|All times are GMT -5. The time now is 09:39 AM.|