Guest User

Untitled

a guest
Jun 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. my @compares1;
  7. my @compares2;
  8.  
  9. open(FILE, "file1.txt") or die("Unable to open file");
  10.  
  11. while(<FILE>)
  12. {
  13. chomp;
  14. my @spaces = split(/ /);
  15. #print $spaces[0] . "\n";
  16. push @compares1, $spaces[0];
  17. }
  18.  
  19. close(FILE);
  20.  
  21. open(F, "file2.txt") or die("Unable to open file");
  22.  
  23. while(<F>)
  24. {
  25. chomp;
  26. my @next = split (/ /);
  27. #print $next[0] . "\n";
  28. push @compares2, $next[0];
  29. }
  30.  
  31. close(F);
  32.  
  33. #print "@compares1\n";
  34. #print "@compares2\n";
  35.  
  36. my $i = 0;
  37. my $status = 0;
  38.  
  39. foreach (@compares1)
  40. {
  41. #print "$_\n";
  42. #print @compares2;
  43. #print "1: $compares1[$i]\n";
  44. #print "2: $compares2[$i]\n";
  45. if ($compares1[$i] ne $compares2[$i])
  46. {
  47. $status = 1;
  48. last;
  49. }
  50. $i++;
  51. }
  52.  
  53. print $status?"Nie OK\n":"OK\n";
Add Comment
Please, Sign In to add comment