home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _42dfe4306e69952ba509053ddcabc2cd < prev    next >
Text File  |  2004-06-01  |  1KB  |  49 lines

  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S %0 %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
  11. goto endofperl
  12. @rem ';
  13. #! /usr/bin/perl -w
  14. #line 15
  15. # computes and prints to stdout the CRC-32 values of the given files
  16. use lib qw( blib/lib lib );
  17. use Archive::Zip;
  18. use FileHandle;
  19.  
  20. my $totalFiles = scalar(@ARGV);
  21. foreach my $file (@ARGV)
  22. {
  23.     if (-d $file)
  24.     {
  25.         warn "$0: ${file}: Is a directory\n";
  26.         next;
  27.     }
  28.     my $fh = FileHandle->new();
  29.     if (! $fh->open($file, 'r'))
  30.     {
  31.         warn "$0: $!\n";
  32.         next;
  33.     }
  34.     binmode($fh);
  35.     my $buffer;
  36.     my $bytesRead;
  37.     my $crc = 0;
  38.     while ($bytesRead = $fh->read($buffer, 32768))
  39.     {
  40.         $crc = Archive::Zip::computeCRC32($buffer, $crc);
  41.     }
  42.     printf("%08x", $crc);
  43.     print("\t$file") if ($totalFiles > 1);
  44.     print("\n");
  45. }
  46.  
  47. __END__
  48. :endofperl
  49.