in reply to comparing 2 files

diff -u file1 file2

If you want to customise the output, you can build your own diff tool around Algorithm::Diff.

If order isn't important and each item appears no more than once per file,

my %seen; ++$seen{$_} while <$fh_in1>; --$seen{$_} while <$fh_in2>; for (keys(%seen)) { print($fh_out1 $_) if $seen{$_} > 0; print($fh_out2 $_) if $seen{$_} < 0; }

If order isn't important and some items might appear more than once in a file,

my %seen1; ++$seen1{$_} while <$fh_in1>; my %seen2; ++$seen2{$_} while <$fh_in2>; print $fh_out1 grep !$seen2{$_}, keys %seen1; print $fh_out2 grep !$seen1{$_}, keys %seen2;

Update: Added tons.