#!/usr/bin/perl # # only-in # find lines which are in the first file, but not in the second. # use warnings; use strict; my ($input_file, $exclude_file) = (shift, shift); die "Usage: $0 INPUT EXCLUDE\n" if ! $exclude_file; my %exclude; open (my $exclude_fh, $exclude_file ) || die "Can't read exclude file '$exclude_file': $!\n"; while (defined(my $exclude = <$exclude_fh>)) { $exclude{$exclude} = 1; } close $exclude_fh; open (my $input_fh, $input_file) || die "Can't read input file '$input_file': $!\n"; while (defined(my $input = <$input_fh>)) { print $input if ! $exclude{$input}; } close $input_fh; #### $ cat file1 $i++; $ only-in file1 file2 Nested quantifiers in regex; marked by <-- HERE in m/^$i++ <-- HERE ; $/ at /home/qmechix/only-in line 27.