Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!wuarchive!udel!rochester!rutgers!mcnc!uvaarpa!mmdf From: frech@mwraaa.army.mil (Norman R. Frech CPLS) Newsgroups: comp.lang.perl Subject: zip search Message-ID: <1990Dec19.140731.26050@uvaarpa.Virginia.EDU> Date: 19 Dec 90 14:07:31 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: frech@mwraaa.army.mil Organization: The Internet Lines: 28 This script is doing what I want, but it is fairly slow. Any suggestions for getting some more speed out of it??? *** cut here *** eval "exec /usr/local/bin/perl -S $0 $*" if $running_under_some_shell; # this emulates #! processing on NIH machines. # (remove #! line above if indigestible) for (@ARGV) { y/a-z/A-Z/; } $temp = join($",@ARGV); print "\nSearching database for @ARGV\n\n"; $recfmt = "a5 A15 a2 x1"; $reclen = length(pack($recfmt,())); open(Z, "zipcodes.dbf") || die; seek(Z,130,0); line: while(read(Z,$rec,$reclen)) { ($zip,$city,$state) = unpack($recfmt,$rec); $templ = join($",$city,$state); last line if $templ =~ /$temp/ ; } close(Z); print "$zip $city $state\n"; # Norm Frech < frech@mwraa.army.mil >