Guest User

Untitled

a guest
Jun 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 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. my @grepNames;
  39.  
  40. foreach (@compares1)
  41. {
  42.  
  43. if ( grep( /$i/, @compares2 ) )
  44. {
  45. print "$compares1[$i]\n";
  46. }
  47. $i++;
  48. }
Add Comment
Please, Sign In to add comment