in reply to compare two files

This is my guess of how to implement my interpretation of your query:
use strict; # get parameters from command line my $fname1 = shift; my $fname2 = shift; my $fnameout = shift; # read in all numbers from file 2 into a hash open( FIN, "<$fname2" ) or die( "Cannot open $fname2: $!" ); my %exclude_num = (); while ( defined( my $line = <FIN> ) ) { # remove trailing newlines $line =~ s/[\r\n]+\z//s; # store number in hash $exclude_num{$line} = 1; } close( FIN ); # read in numbers from file 1, skipping excluded numbers open( FIN, "<$fname1" ) or die( "Cannot open $fname1: $!" ); open( FOUT, ">$fnameout" ) or die( "Cannot create $fnameout: $!" ); while ( defined( my $line = <FIN> ) ) { # remove trailing newlines $line =~ s/[\r\n]+\z//s; # skip excluded numbers next if ( $exclude_num{$line} ); print( FOUT "$line\n" ); } close( FOUT ); close( FIN );