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
In reply to Re: Data Move
by ww
in thread Data Move
by PilotinControl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |