home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / UNIX / GOPHER / GO4GW1.2B / GLOOP.PL < prev    next >
Encoding:
Perl Script  |  1993-07-13  |  1.3 KB  |  51 lines

  1. #!/usr/local/bin/perl -- # -*-Perl-*-
  2.  
  3. # gloop.pl - given a set of newsfroups you want to make visible via
  4. # gopher, gloop out the descriptions from a copy of 
  5. # /usr/local/lib/news/newsgroups...
  6.  
  7. # 1st arg:  groups you want to make visible
  8. # 2nd arg:  /usr/local/lib/news/newsgroups or equivalent
  9. # 3rd args: file to stick the results in
  10.  
  11. ($#ARGV < 2) && 
  12.     die "Usage $0 visible_groups_file newsgroups_file output_file\n";
  13.  
  14. $g2old_groups = $ARGV[0];
  15. $newsgroups = $ARGV[1];
  16. $g2new_groups = $ARGV[2];
  17.  
  18. open(LONG, $newsgroups) || die "Couldn't open $newsgroups!";
  19. while(<LONG>) {
  20.     $_ =~ s/\n//g;
  21.     $_ =~ s/\t+/\t/g;
  22.     ($froup,$nov) = /^(\S+)\s+(.*)$/;
  23.  
  24.     # you might want to add or remove some of these...
  25.     next if $nov =~ /^[xy]$/;
  26.     next if $nov =~ /^alternate group$/;
  27.     next if $nov =~ /^local grp$/;
  28.     next if $nov =~ /^local list$/;
  29.     next if $nov =~ /^[\s\t]+$/;
  30.     next if $nov =~ /^$/;
  31.  
  32.     $mold{$froup} = $nov;
  33. }
  34. close(LONG);
  35.  
  36. open(OLD, $g2old_groups) || die "Couldn't open $g2old_groups!";
  37. open(NEW, ">$g2new_groups") || die "Couldn't open $g2new_groups!";
  38. while(<OLD>) {
  39.     $_ =~ s/\n//g;
  40.  
  41.     if($mold{$_}) {
  42.     print NEW "$_\t$mold{$_}\n";
  43.     }
  44.     else {
  45.     print NEW "$_\t<No description available>\n";
  46.     }
  47. }
  48. close(OLD);
  49. close(NEW);
  50.  
  51.