Re: compare 2 data files and extract fields for matched lines



On Dec 27, shree <srigowr...@xxxxxxxxxxx> wrote:


open (FILE_IN1, $File_In1) or die "cannot open file in FILE_IN1 $!";
@array1 = <FILE_IN1>;
close (FILE_IN1);


Start with two sample files of 2-3 lines each.
Make sure it is okay to read the entire file
in an array by printing the value of @array1
and printing the value of $line1 after running
foreach $line1 (@array1); and read the files
line by line instead of reading them all at once.
Something like :
while ($line1 = <FILE_IN1>) { statements }.
As part of debugging the code, print out the value
of $line1 to see for yourself what strings or arrays
your code is dealing with.

.



Relevant Pages

  • Re: Using an array to search a text file
    ... I get nothing from the foreach/while ... Okay I have that line printing out but it isn't ... looping through the rest of the id array. ...
    (comp.lang.perl.misc)
  • Re: skip last line in loops
    ... how can i skip printing the last line using loops ... I want to skip printing last line of the file.thanks ... if not line1: break ... line2 = myfile.readline ...
    (comp.lang.python)
  • reading line by line
    ... needing to create a big array that contains all these lines (exactly like ... when reading line by line from a text file). ...
    (perl.beginners)