home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1997 March / Simtel-MSDOS-Mar1997-CD1.iso / 00_info / simdisp.pl < prev    next >
Perl Script  |  1996-02-23  |  2KB  |  77 lines

  1. #!/usr/local/perl
  2. #
  3. # simdisp.pl
  4. #
  5. # Prints the SIMTEL file simibm.idx
  6. #
  7. # 900106  Bo Kullmar, bk@kullmar.se
  8. format top =
  9.                          Directory @<<<@<<<<<<<<<<<<<<<<<<<<         Page:@>>
  10.                                    $dev$dir                               $%
  11. Filename    Type Length  Date    Description
  12. ===============================================================================
  13. .
  14. format STDOUT =
  15. @<<<<<<<<<<<<@<<<@>>>>>  @<<<<<  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  16. $file,       $at,$size,  $date,  $comment
  17. .
  18.  
  19. $simfile = "simibm.idx";
  20. @st = lstat($simfile);
  21. $sim_time=&fmt_time($st[9]);
  22.  
  23. print "Simtel.Net Public Domain, Freeware and Shareware list as of $sim_time\n\n";
  24. print "NOTE: Type B is Binary; Type A is ASCII\n\n";
  25. $s- = $s- - 4;
  26.  
  27. open(in, $simfile);        # Open simibm.idx
  28. while (<in>)            # Read one line
  29. {
  30.     chop;            # Remove trailing LF
  31.         ($dev,$dir,$file,$dummy,$size,$type,$date,$comment) = split(/,/,$_,8);
  32.         $dev = substr($dev,1,length($dev)-2);
  33.         $dir = substr($dir,1,length($dir)-2);
  34.         $file = substr($file,1,length($file)-2);
  35.         $comment = substr($comment,1,length($comment)-2);
  36.         if ($type==8) {
  37.             $at= "B";
  38.  
  39.         }
  40.         else {
  41.             $at= "A";
  42.         }
  43.         if ( $ldev ne $dev || $ldir ne $dir ) {        # New page
  44.             if ( $- < 6 ) {
  45.                $- = 0;
  46.             }
  47.             else {
  48.                print "\n                         Directory $dev$dir\n";
  49.                print "Filename    Type Length  Date    Description\n";
  50.                print "===============================================================================\n";
  51.            $- = $- - 4;
  52.             }
  53.         }
  54.         write();        # Write the line
  55.         $ldev = $dev;
  56.         $ldir = $dir;
  57.  
  58. }
  59.  
  60.  
  61. sub fmt_time {
  62.   local ($time) = shift (@_);
  63.   local (@tm) = localtime ($time);
  64.   local ($cent);
  65.   if ($tm[5] < 70) {
  66.      $cent = "20";
  67.   }
  68.   else {
  69.      $cent = "19";
  70.   }
  71.   return
  72.   sprintf ("%s%02d-%02d-%02d %02d:%02d",
  73.          $cent, $tm[5], $tm[4]+1, $tm[3], $tm[2], $tm[1]);
  74.  
  75. }
  76.  
  77.