home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/perl
- # simgrep2.prl - use perl to search a compressed SimTel file list (from
- # simlst.zip) printing findings with directory names, even if the directory
- # name does not contain the search expression.
- # The flag "-a <date>" constrains the match to only those files with a
- # date later than <date>.
- #
- # Based on the simgrep utility.
- #
- # Afzal Ballim (ISSCO, Univ. Geneva) - 21/10/93
- # <afzal@divsun.unige.ch>
- #
- # Last Revised: 3 Nov. 1993
- #
- # Changes: 3/11/93 -- added "after" flag, -a <date>
- # as suggested by Jerry L. Kazdan <kazdan@math.upenn.edu>
-
- #############################################################################
- # Customization section.
- #
- # The compressed file simibm.lst is stored in:
- $COMPFILE="/usr/local/doc/simtel";
- # The program it is to be uncompressed with:
- $COMPPROG="uncompress";
- # The commandline switched needed to get COMPROG to extract a file to stdout:
- $COMPFLAGS="-c";
- #
-
- # get the process name
- # if you are running under UNIX
- $0 =~ s@^.*/@@;
- # if you are running under DOS
- #$0 =~ s@^.*\@@;
-
- # End of customization section.
- #############################################################################
-
- if ($#ARGV != 0 && $#ARGV != 2) {
- print "Usage: $0 [-a <date>] <pattern>\n";
- print " where <pattern> is an egrep pattern,\n";
- print " and <date> is of the form yymmdd.\n";
- exit(1);
- }
-
- $Directory="";
- $MF=0;
- $AFTER=0;
-
- if ($#ARGV > 0) {
- if (shift(@ARGV) eq "-a") {
- $AFTER = shift(@ARGV);
- }
- else {
- die "$0: invalid argument $ARGV[0]\n";
- }
- }
-
- $pattern=shift(@ARGV);
-
- # open the list for reading
- open(SL,"$COMPPROG $COMPFLAGS $COMPFILE |") || die "Couldn't find $COMPFILE\n";
-
- while(<SL>) {
-
- # treat a directory entry specially
- if (/^Directory (.*)/o) {
- $Directory= $1;
- $MF=0;
- }
- elsif (/$pattern/io &&
- /^\w+\.\w+\s+[a-zA-Z]\s+\d+\s+(\d+)/io &&
- $1 > $AFTER) {
- if (!$MF) {
- print "\n$Directory\n";
- $len=length($Directory)-1;
- print "=" x $len, "\n";
- $MF=1;
- }
- print;
- }
- }
-