title: How do I copy data from a defective DVD to my hard disk using Perl?
body: <p>The situation is this: My system (Win XP Pro) is unable to copy a huge video file (around 6 gigs) from a DVD disk, which might be defective, scratched or whatever but which can be played back with mplayer with a few frames full of mosaic though. When the copying process lasted for a certain length of time, the system would abort the effort and give me this warning "A cyclic redundancy check checksum error occurred" . And then everything copied was automatically deleted.</p>
  
  <p>I'm thinking a Perl app might solve the issue. My thought is this: I copy video data one meg at a time. If a reading error ever occurs, I let perl ignore this particular one meg of data and keep copying the rest of the video still one meg at a time.</p>
  
  <p>Incidentally, I've also noticed that some commercial software can do the job, but there're limitations in the trials. </p>
  
  <p>The following script is what I've tried so far. It copies data one meg at a time from the defective dvd disk but it fails like Win XP. The only difference is perl doesn't delete what has already been copied. For my case, it copied around 900 megs of video data to my hard disk and this 900 megs part of the video can still be played back with mplayer. But my goal is to copy all that is good, the majority, only leaving all that is bad, the minority. </p>
  
  <pre><code>    use strict;
      use warnings;
  
      $/ = \1_048_576;  
  
      open my $in, "&lt;", 'D:\tobecopied.mkv' or die $!;
          binmode $in;
      open my $out, "&gt;", 'E:\copied.mkv' or die $!;
          binmode $out;
  
      while (&lt;$in&gt;) {
          print $out $_;
      }
  </code></pre>
  
  <p>The problem is I don't know how to achiev this. Hope someone here can give me a hint or clue. Thanks like always :)</p>