View Single Post
Old 09-09-2004, 06:15 PM   #10
aranpura
Member
aranpura began at the beginning.
 
aranpura's Avatar
 
Posts: 12
Karma: 34
Join Date: Sep 2004
Location: San Francisco, California
Device: Tungsten T3
Also, the Perl script...

In respose to Hacker's inquiry, here's the Perl script for creating the atlas pages from the Mapquest main page. You'll have to pass in the Mapquest page as a shell argument (or in my case a stripped down version of that page).

I'm a real novice at Perl, so please have some leniency with my klutsy approach!

--Ash.



#!/usr/bin/perl

#---- read the input file into the wholePage string

$wholePage = "";
while (<>)
{
$wholePage .= $_;
}


#---- extract the region codes from wholePage into an array

@regionCodes = ();

do
{
push(@regionCodes, $1);
}
while $wholePage =~ /region=(.*?)"/g;


#---- write an HTML atlas page for each region code

foreach $region (@regionCodes)
{
$newFilePath = $region . "Atlas.html";
open(hNewFile, "> $newFilePath")
or die "Couldn't open $path for writing: $!\n";

print hNewFile
"<html>
<p><img src=\"http:\/\/cdn\.mapquest\.com\/mqatlasenglish\/$region\"><\/p>
<p><img src=\"http:\/\/cdn\.mapquest\.com\/mqatlaslocators\/$region\"><\/p>
<\/html>";

close(hNewFile);
}
aranpura is offline