Hey all, I'm trying to read from a file, copy it's contents to another file, then overwrite the first file. >open (INFILE, "<myfirstfile.txt") || die "Error opening myfirstfile.$!,stopped"; >@array1 = <INFILE>; >close(INFILE); >foreach my $rec (@array1) { chomp($rec); ($x,$y,$z) = split(/\|/,$rec); if ($y ne "AK") { #this leaves one record uncopied. open (OUTFILE, ">>mysecondfile.txt") || die "Error opening mysecondfile.$!,stopped"; print OUTFILE "$rec\n"; close(OUTFILE); }; >}; Normally I should just overwrite the first file with an "open", right? >open (OUTFILE, ">myfirstfile.txt") || die "Error opening myfirstfile.$!,stopped"; >print OUTFILE "$a|$b|$c\n"; >close(OUTFILE); Then I can copy the other stuff back replacing the original record with the new one I just pasted in there. >open (INFILE, "<mysecondfile.txt") || die "Error opening mysecondfile.$!,stopped"; >@array2 = <INFILE>; >close(INFILE); >foreach my $rec (@array2) { chomp($rec); open (OUTFILE, ">>myfirstfile.txt") || die "Error opening myfirstfile.$!,stopped"; print OUTFILE "$rec\n"; close(OUTFILE); }; However, I seem to get doubles of the record left behind, the old record does not seem to go away, what am I doing wrong?
Sincerely in Christ, Mark-Nathaniel Weisman President / Owner Outland Domain Group Anchorage, Alaska