in reply to Re^3: Dealing with large files in Perl
in thread Dealing with large files in Perl

Good evening all, No need to response to this as again I got my script to work.. once completed I'll post the codes. Regards,

Replies are listed 'Best First'.
Re^5: Dealing with large files in Perl
by jZed (Prior) on May 23, 2005 at 23:33 UTC
    Thanking people is nice. Telling us what solution you found is even better, because it means someone else can learn from your experience.
      Certainly... I should have done that..

      #!/usr/bin/perl

      &processf();
      use Fcntl ':flock';

      sub processf() {

      unless (open(FILER, "ts-speed.txt")) {
      die ("cannot open input file out2\n");
      }

      $newfile="final.out";

      flock FILE, LOCK_SH;


      while ($line=<FILER>) { # first loop starts here..
      chomp($line);
      my $mymac = substr($line, 0, 12);
      unless (open(FILER2, "docsis-file-orig")) {
      die ("cannot open input file out1\n");
      }

      while ($item=<FILER2>) { # second loop starts here....
      chomp ($item);
      $mymac1 = substr($item, 0, 12);
      if ($mymac =~ /^$mymac1$+/g) {
      unless (open(FILEW, ">>$newfile")) {
      die ("cannot open input file newfile\n");
      }
      flock(FILEW, 2); # file lock set
      printf("'%s' and '%s' are identical\n", $mymac, $mymac1);
      print FILEW ("$item $line\n");
      flock(FILEW, 8); # file lock unset
      close(FILEW);
      } #if end here;
      } #while second end here;
      close(FILER2);


      } #while first end here;


      close(FILER);
      } #sub end here;