Quote:
|
Originally Posted by aranpura
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 don't know what your source file looks like, but here's a cleaned-up version of your Perl, based on knowing very little about what exactly you're doing with it (arg, looks like there are some bugs in the way MR renders code blocks, so this is going to look very disjointed):
PHP Code:
use strict; # ALWAYS use strict
use CGI qw(:html4); # Output HTML cleanly
use File::Slurp; # Suck in the file from disk
my $cgi = CGI->new(); # Create CGI.pm object
my ($wholePage, @regionCodes);
my $page = read_file('that_page');
do {
push( @regionCodes, $1 );
} while $wholePage =~ /region=(.*?)/g;
foreach my $region (@regionCodes) {
my $path = $region . "Atlas.html";
open( hNewFile, "> $path" )
or die "Couldn't open $path for writing: $!\n";
my $data =
$cgi->start_html( -title => "$region" ),
$cgi->p(
$cgi->img({-src =>"http://cdn.mapquest.com/mqatlasenglish/$region"}),
$cgi->img({-src =>"http://cdn.mapquest.com/mqatlaslocators/$region"}),
),
$cgi->end_html;
# Give the user some progress feedback
print "Outputting $region to $path\n";
print hNewFile $data;
close(hNewFile);
}
The rest is up to you.