home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / perl / fgrep.pl < prev    next >
Perl Script  |  1992-03-10  |  463b  |  27 lines

  1. #
  2. #  Just a quick perl fgrep...
  3. #
  4. package fgrep;
  5.  
  6. sub main'fgrep {
  7.     local($file, @exprs) = @_;
  8.     local(@list);
  9.  
  10.     if (open file) {
  11.     $code = "while (<file>) {\n\tchop;\n";
  12.     for (@exprs) {
  13.         $code .= "\tpush(\@list, \$_), next if m\201${_}\201;\n";
  14.     } 
  15.     $code .= "}\n";
  16.     warn "fgrep code is $code" if $debug;
  17.     eval $code;
  18.     warn "fgrep @exprs $file: $@\n" if $@;
  19.     } elsif ($debug) {
  20.     warn "main'fgrep: can't open $file: $!\n";
  21.     } 
  22.  
  23.     @list;
  24.  
  25. 1;
  26.