home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / filedocs / simgrep2.prl < prev    next >
Text File  |  1994-03-04  |  2KB  |  82 lines

  1. #!/usr/local/bin/perl
  2. # simgrep2.prl - use perl to search a compressed SimTel file list (from 
  3. # simlst.zip) printing findings with directory names, even if the directory
  4. # name does not contain the search expression. 
  5. # The flag "-a <date>" constrains the match to only those files with a
  6. # date later than <date>.
  7. #
  8. # Based on the simgrep utility.
  9. #
  10. # Afzal Ballim (ISSCO, Univ. Geneva)  - 21/10/93
  11. # <afzal@divsun.unige.ch>
  12. #
  13. # Last Revised: 3 Nov. 1993
  14. #    
  15. # Changes: 3/11/93 -- added "after" flag, -a <date>
  16. #       as suggested by Jerry L. Kazdan <kazdan@math.upenn.edu>
  17.  
  18. #############################################################################
  19. # Customization section.
  20. #
  21. # The compressed file simibm.lst is stored in:
  22. $COMPFILE="/usr/local/doc/simtel";
  23. # The program it is to be uncompressed with:
  24. $COMPPROG="uncompress";
  25. # The commandline switched needed to get COMPROG to extract a file to stdout:
  26. $COMPFLAGS="-c";
  27. #
  28.  
  29. # get the process name
  30. # if you are running under UNIX
  31. $0 =~ s@^.*/@@;
  32. # if you are running under DOS
  33. #$0 =~ s@^.*\@@;
  34.  
  35. # End of customization section.
  36. #############################################################################
  37.  
  38. if ($#ARGV != 0 && $#ARGV != 2) {
  39.     print "Usage: $0 [-a <date>] <pattern>\n";
  40.     print "      where <pattern> is an egrep pattern,\n";
  41.     print "      and <date> is of the form yymmdd.\n";
  42.     exit(1);
  43. }
  44.  
  45. $Directory="";
  46. $MF=0;
  47. $AFTER=0;
  48.  
  49. if ($#ARGV > 0) {
  50.  if (shift(@ARGV) eq "-a") {
  51.   $AFTER = shift(@ARGV);
  52.  }
  53.  else {
  54.   die "$0: invalid argument $ARGV[0]\n";
  55.  }
  56. }
  57.  
  58. $pattern=shift(@ARGV);
  59.  
  60. # open the list for reading
  61. open(SL,"$COMPPROG $COMPFLAGS $COMPFILE |") || die "Couldn't find $COMPFILE\n";
  62.  
  63. while(<SL>) {
  64.  
  65. # treat a directory entry specially
  66.  if (/^Directory (.*)/o) {
  67.     $Directory= $1;
  68.     $MF=0;
  69.  } 
  70.  elsif (/$pattern/io && 
  71.         /^\w+\.\w+\s+[a-zA-Z]\s+\d+\s+(\d+)/io && 
  72.     $1 > $AFTER) {
  73.     if (!$MF) {
  74.         print "\n$Directory\n";
  75.         $len=length($Directory)-1;
  76.         print "=" x $len, "\n";
  77.         $MF=1;
  78.     }
  79.     print;
  80.  }
  81. }
  82.