C
clearguy02
Hi,
I have two text files: each one has has four fields (delimited by a
space) on each line: id, group, email and manager_id. First file is a
small file with 50 entries and the second one is a huge file with
5,000 entries. The "id" field is same in both files, but the
manager_id's may be different. By comparing all the entries in the
second file (that has the correct manager id), I need to update the
manager_id field in the first file.
Here is the code, I am thinking of:
-----------------------------------------
open (INPUT1,"smallFile.txt") or die "Cannot open the file: $!";
open (INPUT2,"bigFile.txt") or die "Cannot open the file: $!";
while $line1 (<INPUT1>)
{
@small_arr = split /\s+/, $line1;
}
while $line2 (<INOUT2>)
{
@big_arr = split /\s+/, $line2;
}
foreach (@small_arr)
{
if ($small_arr[0] == $big_arr[0] ) # first ID is same in both
files
{
$small_arr[3] = $big_arr[3];
print "$_\n";
}
}
-------------------------------------------------
I know some thing is certainly wrong here. can some one tell me pl.?
Thanks,
J
I have two text files: each one has has four fields (delimited by a
space) on each line: id, group, email and manager_id. First file is a
small file with 50 entries and the second one is a huge file with
5,000 entries. The "id" field is same in both files, but the
manager_id's may be different. By comparing all the entries in the
second file (that has the correct manager id), I need to update the
manager_id field in the first file.
Here is the code, I am thinking of:
-----------------------------------------
open (INPUT1,"smallFile.txt") or die "Cannot open the file: $!";
open (INPUT2,"bigFile.txt") or die "Cannot open the file: $!";
while $line1 (<INPUT1>)
{
@small_arr = split /\s+/, $line1;
}
while $line2 (<INOUT2>)
{
@big_arr = split /\s+/, $line2;
}
foreach (@small_arr)
{
if ($small_arr[0] == $big_arr[0] ) # first ID is same in both
files
{
$small_arr[3] = $big_arr[3];
print "$_\n";
}
}
-------------------------------------------------
I know some thing is certainly wrong here. can some one tell me pl.?
Thanks,
J