#!/usr/bin/perl # fu-remove.pl - given a two lists, remove items in one list from the other # Eric Lease Morgan # April 1, 2013 - first cut # require use strict; # sanity check my $keys = $ARGV[ 0 ]; my $db = $ARGV[ 1 ]; if ( ! $keys or ! $db ) { print "Usage: $0 \n"; exit; } # initialize my %db = (); # slurp up the database open DB, " < $db" or die "Can't open DB ($db): $!\n"; while ( ) { # parse chop; # read my ( $key, @data ) = split /\t/, $_; # store $db{ $key } = [ @data ]; } # compare each given key to an item in the database open KEYS, " < $keys " or die "Can't open KEYS ($keys): $!\n"; while ( ) { # parse chop; # check for existence if ( exists $db{ $_ } ) { # do the work delete $db{ $_ }; } } # process each record in the database foreach ( keys %db ) { # get the data my $data = $db{ $_ }; # print it print "$_\t" . join "\t", @$data, "\n"; } # done exit;