home *** CD-ROM | disk | FTP | other *** search
/ ftp.sunet.sepub/pictures / 2014.11.ftp.sunet.se-pictures.tar / ftp.sunet.se / pub / pictures / ACiD-artpacks / www / mirrors / acheron / cgi-bin / mkdesc.pl < prev    next >
Perl Script  |  1998-12-16  |  2KB  |  79 lines

  1. #!/usr/bin/perl
  2. #########################################################################
  3. #    The function of this program is to generate a description     #
  4. #    file to be used with site_Search version 2.00b. Please        #
  5. #    configure the "site_Search.conf" file for your site before     #
  6. #    running this script. To understand a description read the     #
  7. #    FAQ.html (Q 3 & 4) and the readme.html files.            #
  8. #########################################################################        
  9.  
  10. require("./site_Search.conf") || die "cannot find site_Search.conf file\n";
  11. print "Searching for files ..This may take a moment\n";
  12. &Get_Files_to_Search;
  13.  
  14. open(WRITE,">site_Search.desc") || die 
  15. "Cannot open site_Search.desc for writing, check permissions and try again!!!\n";
  16.  
  17. print scalar(@files_to_be_searched) . " files found, creating site_Search.desc\n"; 
  18. foreach $file (@files_to_be_searched)
  19. {
  20.     print WRITE "$file"."[sep]\n";
  21. }    
  22. print "ALL DONE, site_Search.desc created successfully.\n";
  23.  
  24. sub Get_Files_to_Search{
  25. my $file;
  26.  
  27. @files_from_scandir = &scandir($base_path);
  28.  
  29.  
  30. foreach $file (@files_from_scandir){
  31. push(@files_from_scandir,&scandir($file)) if((-d $file) && (&dirs_avoid($file) ne "0")); 
  32. }
  33.  
  34. foreach $file (@files_from_scandir){
  35. push(@files_to_be_searched,$file) if((&scantype($file) == 1) && (&files_avoid($file) ne "0")); 
  36. }
  37.  
  38. foreach $file (@files_to_include){
  39.         push(@files_to_be_searched,$file);
  40. }
  41. }
  42.  
  43. sub scandir
  44. {
  45.         $directory_to_scan = ($_[0]);
  46.         return(<$directory_to_scan/*>);
  47. }
  48.  
  49. #__Module Returns Only Files of Specified Type__#
  50. sub scantype
  51. {
  52.         foreach $type (@filetypes){
  53.                 return 1 if((rindex $_[0], $type) >= 0);
  54.         }
  55. }
  56.  
  57. #____Module Checks for Validity of Directory____#
  58. sub dirs_avoid
  59. {
  60. my $check_dir = ($_[0]);
  61. my $dir;
  62.  
  63.         foreach $dir (@directories_to_avoid){
  64.                 return 0 if($dir eq $check_dir);
  65.         }
  66. }
  67.  
  68. #______Module Checks for Validity of File______#
  69. sub files_avoid
  70. {
  71. my $check_file = ($_[0]);
  72. my $file;
  73.  
  74.         foreach $file (@files_to_avoid){
  75.                 return 0 if($file  eq $check_file);
  76.         }
  77. }
  78.  
  79.