Home: Need a Custom or Prewritten Perl Program?: Throw Down The Gauntlet:
Script Needed


Jul 10, 2000, 11:16 AM

Views: 7563
Script Needed


I need a fairly simple script where people will search to find a store near them. Basically they just need to be able to enter thier zip code and have stores in the nearby area to show up. This doesn't need to be too fancy as there are only about 250 stores that need to be listed. Please e-mail me at Rhacodactylus@yifan.net for more information. Thank you.


User / Moderator

Jul 10, 2000, 1:35 PM

Views: 7563
Re: Script Needed

For real lookups you'd need zipcode / geocode mapping which isn't free, but a very simple script would be ...
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

#!/usr/bin/perl -wT

## By Kanji T Bates <kanji@perlguru.com>

use strict;
use CGI qw(:standard);

print header, start_html( -title => 'Store Locator' );

my @stores;
if ( my $zip = param('zip') ) {
if ( $zip =~ /^\d{5}$/ ) {
while ( <DATA> ) {
push @stores, [ (split /:/)[0..5] ]
if /:$zip:/
&& /:Y$/;

if ( @stores ) {
print h2( "These stores are in/near $zip..." );

foreach my $store ( @stores ) {
printf( "<hr><b>%s</b><br>%s<br>%s, %s %s<br>%s" => @$store );
} else {
print h2( "Sorry, there are no stores in/near $zip." );
} else {
print h2( "$zip isn't valid. Please re-enter a 5 digit zip." );

print hr, "Search again? ";

print start_form, "Enter a 5 digit zip: ",
textfield( -name => 'zip', -maxlength => 5 ),


Buy From Us:5 Some St:Some Town:ST:05000:123-456-7890:05001:05002:05003:05012:Y
Another Company:15 A St:Some Town:ST:05000:456-789-0123:05001:05002:05003:05012:N
Buy From Them:10 Another St:Another Town:AT:43006:234-567-8901:43002:05001:Y</pre><HR></BLOCKQUOTE>

[This message has been edited by Kanji (edited 07-10-2000).]