#!/usr/bin/perl use strict; use warnings; my $table_list_file = shift; # first command-line arg my $table_db_list_file = shift; # second arg my %tables; open( I, "<", $table_list_file ) or die "$table_list_file: $!"; while () { chomp; $tables{$_} = undef; } open( I, "<", $table_db_list_file ) or die "$table_db_list_file: $!"; while () { my ( $table_name, $db_name ) = split; # or maybe it's the other way around? if ( $tables{$table_name} ) { # seen in first file? print; } } #### cmpcol -i -l2 table.list table_db.list #### script.file [-options] file1 file2 > output.list