home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / Perl / RPC / !Perl / scripts / FindModVer < prev    next >
Text File  |  1998-07-14  |  1KB  |  66 lines

  1. #!perl -w
  2. # Version 0.01
  3. use RISCOS::Filespec;
  4.  
  5. # use RISCOS::File ':DEFAULT', '/glob/';
  6. # glob_control (&fileglob_PrintOriginalPath);
  7.  
  8. $/ = "\0";    # Read null termintated lines
  9.  
  10. foreach $pattern (@ARGV)
  11. {
  12.     foreach $file (glob($pattern))
  13.     {
  14.     unless (open (MOD, "<$file"))
  15.     {
  16.         warn "Could not open file '$file': $!";
  17.         next;
  18.     }
  19.  
  20.     unless (seek MOD, 0x14 ,0)
  21.     {
  22.         warn "Could not seek to &14 in file '$file': $!";
  23.         next;
  24.     }
  25.  
  26.     unless (read MOD, $where ,4)
  27.     {
  28.         warn "Could not read help offset from file '$file': $!";
  29.         next;
  30.     }
  31.  
  32.     $where = unpack 'I', $where;
  33.     # Hmm. there's no unsigned V to force read little endian
  34.  
  35.     unless ($where)
  36.     {
  37.         warn "Zero offset of help text in '$file'";
  38.         next;
  39.     }
  40.  
  41.     if ($where > ($length = -s $file))
  42.     {
  43.         warn "Offset of help text in '$file' at $where > length ($length)";
  44.         next;
  45.     }
  46.  
  47.     unless (seek MOD, $where ,0)
  48.     {
  49.         warn "Could not seek to $where in file '$file': $!";
  50.         next;
  51.     }
  52.     
  53.     unless (defined ($text = <MOD>))
  54.     {
  55.         warn
  56.           "Could not read help text at offset $where in file '$file': $!";
  57.         next;
  58.     }
  59.     
  60.     # Hey, got the text.
  61.     chomp $text;
  62.     
  63.     print "$file:\n\t$text\n";
  64.     }
  65. }
  66.