Guest User

print uniques from the -b file only

a guest
Jun 15th, 2021
19
6 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. use Getopt::Long ();
  6. Getopt::Long::Configure( 'bundling' );
  7.  
  8. my %OPTS;
  9. Getopt::Long::GetOptionsFromArray( \@ARGV,
  10.     'a=s' => \$OPTS{A},
  11.     'b=s' => \$OPTS{B},
  12. ) or die("Bad options");
  13.  
  14. open( my $orig, '<', $OPTS{A} )
  15.     or die("Open file-A failed: $!");
  16. open( my $new, '<', $OPTS{B} )
  17.     or die("Open B failed: $!");
  18.  
  19. my %SEEN;
  20. while (<$orig>) {
  21.     chomp;
  22.     next if( length($_) < 1 );
  23.     $SEEN{$_} = 1;
  24. }
  25. close($orig);
  26.  
  27. while(<$new>) {
  28.     chomp;
  29.     next if( length($_) < 1);
  30.     next if( exists $SEEN{$_} );
  31.     $SEEN{$_} = 1;
  32.     printf("%s\n", $_);
  33. }
  34.  
  35. close($new);
RAW Paste Data