if ( -f $working_file ) { open WORKINGFILE, "<$working_file" or die $!; while () { $line = $_; #@storelist - I am getting this thru a sql statement foreach $temp (@storelist) { chomp $temp; ($x,$store,$distri,$end_date)=split(';',$temp); chomp $store,$distri,$end_date; # print LOG "The store in the lookup is $store and the distributor is $distri\n"; if ( "$store" ne "" && "$end_date" eq "" ) { if ( substr($_,0,4) =~ "$store" ) { open NEWFILE,">>$temp_dir$next_file" or warn $!; print NEWFILE $_; # delete $_ from $working_file ?????????? HOW ???? } } }