home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / Scripts / searchdbf.pl < prev    next >
Encoding:
Perl Script  |  2017-09-22  |  5.2 KB  |  211 lines

  1. #!/usr/bin/perl
  2. # search for specific pavilion 
  3. # parameters: info to look at
  4.  
  5. # Philippe T., 07 /08 /96
  6.  
  7. #----------------------------------------
  8. # Global Variables 
  9. #----------------------------------------
  10.  
  11.  
  12.        #======== TO BE MODIFIED 
  13. $defaultlocation="/cp/htdocs/";
  14. $defaultcp="/usr/bin/cp";
  15.  
  16. $dbf_file="/cp/htdocs/Scripts/votedbf.dbf";
  17. $ftheme_dic=$defaultlocation."Scripts/theme_dic.txt";
  18. $fregion_dic=$defaultlocation."Scripts/country_dic.txt";
  19. $datab_file=$defaultlocation."Scripts/fulldbf.dbf";
  20. $datab_new=$defaultlocation."Scripts/fulldbf.NEW.dbf";
  21. $log_file=$defaultlocation."Scripts/output_errors.log";
  22. $log_add_theme=$defaultlocation."Scripts/add_log_theme.log";
  23. $log_add_region=$defaultlocation."Scripts/add_log_region.log";
  24. $log_label=$defaultlocation."Scripts/labels.log";
  25. $catalog_file=$defaultlocation."Scripts/theme_catalog.dbf";
  26. $World=$defaultlocation."Pavilions/People/World/";
  27.  
  28.           #=========== Global Variables
  29. $pav_name="";
  30. $description="";
  31. $url="";
  32. $theme="";
  33. $country="";
  34. $label="";
  35. $where_theme="";
  36. $where_region="";
  37. $where_people="";
  38. $email="";
  39. $side="";
  40. $size="224";
  41. $postcard="";
  42. @database="";
  43. @theme_dic="";
  44. @region_dic="";
  45. @people_dic="";
  46. @catalog="";
  47.  
  48. open (CAT, $catalog_file) ||die "could not open catalog file\n";
  49. $datab_file=$ARGV[0];
  50. @catalog=<CAT>;
  51. close(CAT);
  52.  
  53. $toto=$ARGV[0];
  54. $toto=~tr/A-Z/a-z/;
  55. print "+++++++++++++++ARGUMENTS:$toto\n";
  56. &open_dictionnary();
  57. &go();
  58.  
  59.  
  60.  
  61. sub go {
  62. local($temp);
  63. $temp="";
  64.  
  65. open (DICT,$dbf_file) || die "Oups, could not open the labels : $dbf_file $!\n";
  66. while ($temp = <DICT>)
  67.  {
  68.   chop($temp);
  69.   $tempo=$temp;
  70.   $tempo=~tr/A-Z/a-z/;
  71.   if($tempo=~/$toto/) { &list_to_name($temp); &print_info();}
  72.  }
  73. close(DICT);
  74. }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. sub list_to_name {
  82. local($string)=@_;
  83. local($d1,$d2,$d3,$d4,$d5,$d6,$d7,$d8,$d9,$d10,$d11,$d12)=split(/#/,$string,12);
  84. $pav_name=&ba_space($d1);
  85. $description=&ba_space($d2);
  86. $url=&ba_space($d4);
  87. $theme=&ba_space($d6);
  88. $country=&ba_space($d8);
  89. $email=&ba_space($d11);
  90. $label=&do_label($pav_name);
  91. $label="/Images/Labels/".$label.".jpg";
  92. $where_theme=$defaultlocation."Pavilions/".$theme_dic{$theme};
  93. $where_region=$defaultlocation.$region_dic{$country};
  94. $where_people=$defaultlocation.$people_dic{$country};
  95. }
  96.  
  97.  
  98. sub ba_space {
  99.  local($string)=@_;
  100.  while (($last=chop($string)) eq ' ' )  { }
  101.    $string=$string.$last;
  102.  while ($string=~/^ /) { $string=substr($string,1,length($string)); }
  103. $string;
  104. }
  105.  
  106. sub do_label {
  107.  local($string)=@_;
  108.  $string=&ba_space($string);
  109.    $string=~ s/"//g;
  110.    $string=~ tr/A-Z/a-z/;
  111.    $string=~ s/ /_/g;
  112.    $string=~ s/'//g;
  113.    $string=~ s/`//g;
  114.    $string=~ s/~//g;
  115.    $string=~ s/\&//g;
  116.    $string=~ s/\+//g;
  117.    $string=~ s/\,//g;
  118.    $string=~ s/\(//g;
  119.    $string=~ s/\)//g;
  120.    $string=~ s/\.//g;
  121.    $string=~ s/\:/_/g;
  122.    $string=~ s/\*//g;
  123.    $string=~ s/\//_/g;
  124.    $string=~ s/\-/_/g;
  125.    $string=~ s/__/_/g;
  126. $string;
  127. }
  128.  
  129.  
  130. sub print_info {
  131.  print "Pav Name:$pav_name\n";
  132.  print "Descripi:$description\n";
  133.  print "URL     :$url\n";
  134.  print "THEME   :$theme\n";
  135.  print "Country :$country\n";
  136.  print "Email   :$email \n";
  137.  print "++++++++Info generated++++++:\n";
  138.  $side="1";
  139.  &check_label($label);
  140.    if ($country eq "United States") {
  141.       $char=substr($pav_name,0,1);
  142.       $char=~tr/a-z/A-Z/;
  143.       if ($char =~ /[A-E]/) { $dir=$defaultlocation."UnitedStates/A_E/"; }
  144.       if ($char =~ /[F-J]/) { $dir=$defaultlocation."UnitedStates/F_J/"; }
  145.       if ($char =~ /[K-N]/) { $dir=$defaultlocation."UnitedStates/K_N/"; }
  146.       if ($char =~ /[O-R]/) { $dir=$defaultlocation."UnitedStates/O_R/"; }
  147.       if ($char =~ /[S-V]/) { $dir=$defaultlocation."UnitedStates/S_V/"; }
  148.       if ($char =~ /[W-Z]/) { $dir=$defaultlocation."UnitedStates/W_Z/"; }
  149.      $where_region=$dir;
  150.    }
  151.  
  152.  print "Label   :$label ACTUALL SIDE:$side\n";
  153.  print "dir Them:$where_theme\n";
  154.  print "dir regi:$where_region\n";
  155.  if ($theme eq "people" ){
  156.  print "dir peop:$where_people\n";}
  157.  print "=======================================================\n";
  158. }
  159.  
  160. sub check_label {
  161.  local($nom)=@_;
  162.  local($i)=0;
  163.  local($sideLR)="1";
  164. $i=0;
  165. while  ((!($catalog[$i]=~/$nom/)) && ($i<=$#catalog)) {$i++;}
  166. if ($catalog[$i]=~/$nom/)
  167.               {
  168.                   #print "FOUND OK $catalog[$i]\n";
  169.                   local($d1,$d2,$d3,$d4,$d5,$d6,$d7)=split(/#/,$catalog[$i],7);
  170.                   #$sideLR=$d5;
  171.                   $side=$d6;
  172.               }
  173.               else
  174.               {
  175.                  print "PROBLEM WITH LABEL NOT FOUND or MISS NAMED\n";
  176.               }
  177. #$sideLR;
  178. $side;
  179. }
  180.  
  181.  
  182. sub open_dictionnary{
  183. local($temp);
  184. open (DICT,$ftheme_dic) || die "Oups, could not open the theme dictionnary: $fth
  185. eme_dic $!\n";
  186. $temp="";
  187. while ($temp = <DICT>)
  188.  {
  189.   chop($temp);
  190.   local($name_datab,$location,$url_name)=split(/#/,$temp,3);
  191.   #print "DIC: $name_datab,$location,$url_name\n";
  192.   $theme_dic{$name_datab}=$location;
  193.  }
  194. close (DICT);
  195. #print "Ok, I've got  the info I need from the theme dictionnary!, now opening the regions....\n";
  196. open (DICT,$fregion_dic) || die "Oups, could not open the region dictionnary: $fregion_dic $!\n";
  197. $temp="";
  198. while ($temp = <DICT>)
  199.  {
  200.   chop($temp);
  201.   local($t1,$t2,$t3,$t4,$t5,$t6,$t7)=split(/#/,$temp,7);
  202.   #print "DIC REGION : $t1,$t2,$t5,$t6,$t7\n";
  203.   $region_dic{$t1}=$t2;
  204.   $people_dic{$t1}=$t5;
  205.  }
  206. close(DICT);
  207. #print "Ok, I've got almost everything I need.....\n";
  208. #print "let's go......\n";
  209. }
  210.  
  211.