#************************************************************ #** This Perl example is provided "as is". This code is ** #** not supported, but I will try to answer questions as ** #** time allows. Email: wizjd@panix.com ** #** Visit: for updated, ** #** and new examples. ** #************************************************************ #!/usr/local/bin/perl print("Content-Type: text/html\n\n"); print("Clickmap Example Page\n"); print("\n"); ($clicked_x, $clicked_y) = split(/,/,$ENV{QUERY_STRING}); #print "x=", $clicked_x, " y =", $clicked_y, "
\n"; #look thru our coordinates file for state this x/y belongs too. open(INFILE,"states.dat"); $got_state = ""; while () { chop; ($state_name, $x1, $y1, $x2, $y2) = split(/:/); if( $clicked_x > $x1 && $clicked_x < $x2 && $clicked_y > $y1 && $clicked_y < $y2 ) { $got_state = $state_name; } } if ($got_state eq "") { print "

ERROR: Please Click on the BLUE State Name.

\n"; } else { print "

You clicked on ", $got_state, "

\n"; } print "
"; print "
Back to Map of USA\n"; print "
Back to Examples Page\n"; quit: print(""); print(""); #This is the contents of "states.dat" the file with our #State/Co-ordinate data: # #Alabama:316:183:360:192 #Alaska:26:22:67:34 #Arizona:118:171:158:182 #Arkansas:270:163:315:171 #California:38:142:89:154 #Colorado:168:119:212:130 #Conneticut:467:102:522:113 #Delaware:451:128:506:138 #Florida:365:210:401:220 #Georgia:364:181:407:194 #Hawaii:6:114:46:127 #Idaho:111:79:139:89 #Illinois:301:104:337:116 #Indiana:322:116:362:125 #Iowa:265:89:298:101 #Kansas:226:125:266:136 #Kentucky:322:133:375:144 #Louisiana:267:193:321:204 #Maine:464:35:498:48 #Massachusetts:449:90:527:100 #Michigan:341:81:390:91 #Minnesota:264:40:318:52 #Missisippi:292:172:351:181 #Montana:135:49:181:59 #Nebraska:208:99:256:111 #Nevada:80:112:120:121 #New Mexico:166:148:203:172 #New Hampshire:449:75:526:82 #New Jersey:451:113:512:126 #New York:391:83:444:93 #North Dakota:213:38:250:62 #North Carolina:374:148:452:158 #Ohio:359:102:384:111 #Oklahoma:231:149:284:160 #Oregon:56:74:96:85 #Pennslyvania:389:102:453:113 #South Carolina:380:163:458:175 #South Dakota:211:67:247:90 #Tennesee:312:144:368:156 #Texas:223:186:255:195 #Utah:131:115:158:126 #Vermont:413:62:456:72 #Virginia:390:133:435:143 #Washington:36:47:95:59 #West virginia:366:117:439:128 #Wisconsin:290:63:343:75 #Wyoming:153:85:198:96 #MaryLand:467:140:519:149 #Rhode Island:460:153:525:161