CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



ChameleonCamo
Deleted

Jul 10, 2000, 11:16 AM

Post #1 of 2 (4118 views)
Script Needed Can't Post

Hi,

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.

Kate


Kanji
User / Moderator

Jul 10, 2000, 1:35 PM

Post #2 of 2 (4118 views)
Re: Script Needed [In reply to] Can't Post

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 ),
end_form,
end_html;


__DATA__
STORE:STREET:TOWN:STATE:ZIP:PHONE:NEAR-BY ZIPS:ACTIVE

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).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives