And here is (roughly) the same in
Perl:
Code:
perl -ane 'BEGIN { open FILE1, ">file1.both"; open FILE2, ">file2.both"; }
if ($. == ++$n) { $h{$F[2]} = $_; close ARGV if eof; next; }
if ($h{$F[2]}) { print FILE1 $h{$F[2]}; print FILE2; }' file1 file2
This isn't very idiomatic
Perl, but should hopefully be enough to get you started. The trickery with
$n and
ARGV is to simulate the awk
NR==FNR idiom. The
eof thing is to reset line numbers in
$. when the file changes; see the
eof documentation for a brief discussion.
By the way, $3 in
6515152 52272 * ConstMethodKlass is just "*" -- maybe you want to normalize that, rather than change the script.