Write a Perl program that, given a ZIP code as a command-line argument, prints a list of nearby restaurants, in XML format.
As a data source, you can use this RDF fragment (also available in Oncourse) from chefmoz.org (for full data and use license, go to http://chefmoz.org/rdf.html). Your script will have to use regular expressions to extract the restaurant records matching the ZIP code.
For the output XML, use the
geoRSS format
as described in the
Yahoo!
Maps Simple API Reference Manual (see sample XML file; use
addresses rather than geo-coordinates; no need for groups).
Project checkpoint 2
Write a Perl program that, given a ZIP code as a command-line argument, saves a list of nearby restaurants in an XML file.
As a data source, use the full RDF dump that you can
download from
http://chefmoz.org/rdf.html
(be sure to abide by the Chef Moz use license). Given the huge
size of this RDF source file, your script would be too slow if it
used regular expressions to extract the restaurant records each time
a ZIP code is issued (imagine doing this thousands of times!).
Therefore, you will have to first write another script to extract
all restaurant records by parsing the RDF file, and save them in
a database for later lookup. You can use the DB_File
module to create Berkeley database files with
the restaurant records. Design your database so that you can
quickly extract all the desired records, without looking through the
entire database (hint: you will need an index). Once the database
is constructed, the main script will use the DB_File
module to query the database and quickly retrieve all the
restaurant records matching the input ZIP.
For the output XML, use the same geoRSS format as for
project checkpoint 1. Then, use the
Yahoo!
Maps Simple API to create an interactive map with the
matching restaurants. You will need to get a free application ID
first, then pass your XML file to api.maps.yahoo.com
in a REST query (follow the
Yahoo!
Maps Simple API documentation).
Project checkpoint 3
Write a Perl CGI script to create a dynamic web page with a form to input a ZIP code. Once the user submits a ZIP code, the script will generate a cool interactive satellite map with nearby restaurants.
As a data source, use the database that you built in project checkpoint 2 starting from the full Chef Moz RDF dump (be sure to abide by the Chef Moz use license).
To generate the map, use the
Yahoo!
Maps AJAX API (reuse your application ID from project checkpoint 2).
Your CGI script will dynamically generate an HTML
page to overlay GeoRSS data on the map. Follow the
example
in the documentation to see how you can use an existing XML data file,
which your script will create on the fly as in project checkpoint 2.
Final project
Extend the code you developed in the project checkpoints to develop a dynamic web site in Perl that allows users to find restaurants. The site should allow various input criteria such as ZIP, city, address, food type, etc. The output should be a cool and fast interactive map with restaurants matching the user criteria. In addition to the map, the site should also display a list of restaurant hits ranked by ratings. The site should display ratings, reviews, and other restaurant information when the user clicks on any marker in the map or link in the list. Here are some examples from earlier terms: