X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fcreate_prefix.pl;h=f1a0b554856f132be04df0a5b653f621ff6a440e;hb=8be46ac1786265a7ba6ee91b31141ecd017ecb49;hp=daf4a09e409171cb1433b068aa9aa9a8c1d218c6;hpb=c94ff1bf2cbe16ed59c5b273c7f6730fd7314cab;p=spider.git diff --git a/perl/create_prefix.pl b/perl/create_prefix.pl index daf4a09e..f1a0b554 100755 --- a/perl/create_prefix.pl +++ b/perl/create_prefix.pl @@ -6,7 +6,7 @@ # # -require 5.004; +use 5.10.1; # search local then perl directories BEGIN { @@ -20,6 +20,7 @@ BEGIN { unshift @INC, "$root/local"; } +use DXVars; use SysVar; use Data::Dumper; @@ -33,18 +34,26 @@ my %locn = (); # the inverse of the above my %pre = (); # the prefix hash my %pren = (); # the inverse -if (@ARGV && $ARVG[0] =~ /^--system$/) { +my $prefix; +my $system; + +if (@ARGV && $ARGV[0] =~ /^-?-?syst?e?m?$/) { $prefix = $main::data; + ++$system; shift; + say "create_prefix.pl: creating SYSTEM prefix files"; } else { - $prefix = $main:local_data; + $prefix = $main::local_data; + say "create_prefix.pl: creating LOCAL prefix files"; } -# open the input file -my $ifn = $ARGV[0] if $ARGV[0]; +my $ifn; -$ifn = "$prefix/wpxloc.raw" if !$ifn; -open (IN, $ifn) or die "can't open $ifn ($!)"; +$ifn = $system ? "$main::data/wpxloc.raw" : "$prefix/wpxloc.raw"; +unless (open (IN, $ifn)) { + $ifn = "$main::data/wpxloc.raw"; + open(IN, $ifn) or die "can't open $ifn ($!)"; +} # first pass, find all the 'master' location records while () { @@ -104,10 +113,17 @@ close(IN); #print Data::Dumper->Dump([\%pre, \%locn], [qw(pre locn)]); # now open the cty.dat file if it is there +my $r; +$ifn = $system ? "$main::data/cty.dat" : "$prefix/cty.dat"; +unless ($r = open (IN, $ifn)) { + $ifn = "$main::data/cty.dat"; + $r = open(IN, $ifn); +} + my @f; my @a; $line = 0; -if (open(IN, "$prefix/cty.dat")) { +if ($r) { my $state = 0; while () { $line++;