#!/usr/bin/env perl -w if(scalar(@ARGV) != 3){ die "Usage: dc inputfile.txt excludefile.txt outputfile.txt \n" ; } open(INPUT, "$ARGV[0]") or die "Error opening input: $!\n"; #And now we start to go through the file while(){ #copy in lines as strings @sentance = split(/\s+/); #split at any whitespace, tab, newline etc foreach $word (@sentance){ @count = split(//, $word); $word=~s/\W//g; if((scalar(@count)) >= 4){ $allow = 1; open(EXCLUDE, "$ARGV[1]") or die "Error opening exclusion file: $!\n"; open(OUT, "+>>$ARGV[2]") or die "Error opening output file: $!\n"; while(){ chomp $_; if($word eq $_){ print "match \n"; $allow = 0 } } while(){ #getting in here is the problem print "in the zone \n"; #print this if we get in here chomp $_; if($word eq $_){ $allow = 0; } } if($allow == 1){ print "$word\n"; }else{ print "allow is $allow\n"; } print OUT "$word\n" if $allow == 1; close(EXCLUDE); close(OUT); }