in reply to Data Move

PilotinControl: As I was checking to see that I was citing the correct line numbers in preparing to observe that your (ORIGINAL!) Ln 35 trashes the previous array created with data from Ln 34 each time thru the foreach loop, I found that you've replaced the code -- with an update note to be sure, but with no indication of how the line numbers changed.

Downvoted, for that, and your consistent habit of ignoring PM's standards and for asking questions to which you've previously been given good answer.

And, lest you've trashed the context of other answers, here's the original (the lines cited in para 1 are now 50-51 in your updated OP):

use strict; use warnings; use File::Copy; sub update_record_now { my ($rcid,$car,$owner) = @_; open my $infile, '<','cardata.txt' or die $!; open my $outfile, '>', 'cartemp.txt' or die $!; while (<$infile>) { s/^$rcid\:.*/$rcid\:$car\:$owner/g; print $outfile $_; } my $pinfile = "cardata.txt"; my @data; { open(my $data_file_handle, '<', "$pinfile") or die("Can't open file: $ +pinfile"); @data = <$data_file_handle>; close($data_file_handle); close $pinfile; } chomp(@data); open(my $out_file_handle,'>', $pinfile) or die("Can't open file: $pinf +ile"); foreach my $line_from_file ( @data ) { my @field = split( /\:/, $line_from_file ); next if( $field[0] == $rcid ); print $out_file_handle $line_from_file, "\n"; } close $pinfile; close $out_file_handle; close $infile; close $outfile; move 'cartemp.txt', 'updatedcardata.txt'; } __DATA__ 1:Chevy:Bob 2:Ford:Tom 3:Fiat:Dave

Replies are listed 'Best First'.
Re^2: Data Move
by PilotinControl (Pilgrim) on May 27, 2015 at 16:29 UTC

    And again...I will explain the issue:
    1.) The code deletes the data line from one file and moves it to another. Which is what I want.
    2.) However, ALL lines from file (1) are also sent to file (2) and that is not what is desired.
    The answer provided does not address this issue.

      Problem solved...thanks for any and all advice from everyone in the monestary..it helps to have multiple eyes looking over code than just one set!