in reply to a one-liner for this trivial problem?

You do it the other way round: first you read the smaller file into a hash. Then you open the bigger file, check for each ID if it exists in the hash and only print if it does not.

Replies are listed 'Best First'.
Re^2: a one-liner for this trivial problem?
by Anonymous Monk on Apr 16, 2013 at 14:47 UTC
    Yeah, true, I was just hoping there could be an one-liner solution to this, and not need to write a "normal" script...

      You can do that in one line. The easiest way is to use a really long line and to fill that line by removing all line breaks from the script.

      Maybe you can show us the code you've already written to solve the problem. Then we can help you with the technical hurdles that might prevent that code from working as a one-liner.

        Something like this...
        ($small_file, $big_file) = @ARGV; open SMALL, $small_file; while(<SMALL>) { $id_to_remove=$_; chomp $id_to_remove; $hash_to_remove{$id_to_remove} = $id_to_remove; } close SMALL; open BIG, $big_file; while(<BIG>) { $id_to_check=$_; chomp $id_to_check; if(not exists $hash_to_remove{$id_to_check}) {print $id_to_check."\n";} } close BIG;