Skip to main content
deleted 20 characters in body
Source Link
perl -F\\. -lane '
   $h{@ARGV}{$F[0]}++,next if @ARGV;
   print if exists $h{2}{$_} && !exists $h{1}{$_};
' up.txt dw.txt a.txt

Build up the hash %h with top level keys as "2" and "1", with 2 referring to the first argument (up.txt), 1 referring to dw.txt. For the data given, the hash structure would look something like:(the order could differ)

%h = (
   1 => { a => 1, b => 1, },
   2 => { a => 1, b => 1, c => 1, d => 1, e => 1, },
);

as can be seen there are two mini-hashes inside the main hash %h. So when the time comes to read in the third argument (a.txt), we make the decision to print the record based on the whether that record can be seen (as a key) in the mini-hash %2 AND not seen in the mini-hash %1, inside the main hash %h (also referred to as a hash-of-hashes, or HoH).

perl -F\\. -lane '
   $h{@ARGV}{$F[0]}++,next if @ARGV;
   print if exists $h{2}{$_} && !exists $h{1}{$_};
' up.txt dw.txt a.txt

Build up the hash %h with top level keys as "2" and "1", with 2 referring to the first argument (up.txt), 1 referring to dw.txt. For the data given, the hash structure would look something like:(the order could differ)

%h = (
   1 => { a => 1, b => 1, },
   2 => { a => 1, b => 1, c => 1, d => 1, e => 1, },
);

as can be seen there are two mini-hashes inside the main hash %h. So when the time comes to read in the third argument (a.txt), we make the decision to print the record based on the whether that record can be seen (as a key) in the mini-hash %2 AND not seen in the mini-hash %1, inside the main hash %h (also referred to as a hash-of-hashes, or HoH).

perl -F\\. -lane '
   $h{@ARGV}{$F[0]}++,next if @ARGV;
   print if exists $h{2}{$_} && !exists $h{1}{$_};
' up.txt dw.txt a.txt

Build up the hash %h with top level keys as "2" and "1", with 2 referring to the first argument (up.txt), 1 referring to dw.txt. For the data given, the hash structure would look something like:(the order could differ)

%h = (
   1 => { a => 1, b => 1, },
   2 => { a => 1, b => 1, c => 1, },
);

as can be seen there are two mini-hashes inside the main hash %h. So when the time comes to read in the third argument (a.txt), we make the decision to print the record based on whether that record can be seen (as a key) in the mini-hash %2 AND not seen in the mini-hash %1, inside the main hash %h (also referred to as a hash-of-hashes, or HoH).

Source Link

perl -F\\. -lane '
   $h{@ARGV}{$F[0]}++,next if @ARGV;
   print if exists $h{2}{$_} && !exists $h{1}{$_};
' up.txt dw.txt a.txt

Build up the hash %h with top level keys as "2" and "1", with 2 referring to the first argument (up.txt), 1 referring to dw.txt. For the data given, the hash structure would look something like:(the order could differ)

%h = (
   1 => { a => 1, b => 1, },
   2 => { a => 1, b => 1, c => 1, d => 1, e => 1, },
);

as can be seen there are two mini-hashes inside the main hash %h. So when the time comes to read in the third argument (a.txt), we make the decision to print the record based on the whether that record can be seen (as a key) in the mini-hash %2 AND not seen in the mini-hash %1, inside the main hash %h (also referred to as a hash-of-hashes, or HoH).