home *** CD-ROM | disk | FTP | other *** search
/ ftp.madoka.org / 2014.12.ftp.madoka.org.tar / ftp.madoka.org / pub / plum / plum2_33_1.lzh / support / modinfo < prev    next >
Text File  |  1999-03-24  |  2KB  |  71 lines

  1. #!/bin/perl -w
  2. # $Id: modinfo,v 2.9 1998/11/11 03:25:45 hasegawa Exp $
  3. # copyright (c)1997-1998 Yoshinori Hasegawa <hasegawa@madoka.org>
  4.  
  5. &main(@ARGV);
  6.  
  7. sub main {
  8.   local(@args) = @_;
  9.   local($dir);
  10.   if (!@args) {
  11.     &usage();
  12.     exit(1);
  13.   }
  14.   $dir = shift(@args);
  15.   &traverse("$dir/module", '');
  16. }
  17.  
  18. sub traverse {
  19.   local($base, $dir) = @_;
  20.   local(@files, $file);
  21.   opendir(DIR, "$base/$dir") || die;
  22.   @files = readdir(DIR);
  23.   closedir(DIR);
  24.   foreach $file (sort(@files)) {
  25.     next if $file =~ /^\./;
  26.     next if $file eq 'SCCS';
  27.     next if $file eq 'RCS';
  28.     next if $file eq 'CVS';
  29.     next if $file =~ /\,v$/;
  30.     if (-d "$base/$dir/$file") {
  31.       if ($dir) {
  32.         &traverse($base, "$dir/$file");
  33.       } else {
  34.         &traverse($base, $file);
  35.       }
  36.     } elsif ($file =~ /\.plm/) {
  37.       if ($dir) {
  38.         print "<DT><A HREF=\"../module/$dir/$file\">$dir/$file\n";
  39.         print "</A></DT>";
  40.         &info("$base/$dir/$file", "$dir/$file");
  41.       } else {
  42.         print "<DT><A HREF=\"../module/$file\">$file\n";
  43.         print "</A></DT>";
  44.         &info("$base/$file", $file);
  45.       }
  46.     }
  47.   }
  48. }
  49.  
  50. sub info {
  51.   local($file, $name) = @_;
  52.   if (open(FILE, $file)) {
  53.     while (defined($line = <FILE>)) {
  54.       $line =~ tr/\r\n//d;
  55.       last if $line eq '__END__';
  56.     }
  57.     while (defined($line = <FILE>)) {
  58.       $line =~ tr/\r\n//d;
  59.       if ($line =~ /^\s*$name\s*\-\s*(.*)$/) {
  60.         print "<DD>    $1\n";
  61.         print "</DD>\n";
  62.       }
  63.     }
  64.     close(FILE);
  65.   }
  66. }
  67.  
  68. sub usage {
  69.   print 'usage: perl modinfo <plum-top-directory>', "\n";
  70. }
  71.