deep_rastogi has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Input Output file
by pc88mxer (Vicar) on Apr 18, 2008 at 19:39 UTC
    Here's a basic idea of how I might approach this problem.
    1. Open 1.txt and read its contents into a data structure suitable for later use.
    2. Process each line of 2.txt. Change the line based on the data read in step 1, and write it to a third file.
    3. When processing of 2.txt is complete, rename the third file to 2.txt
    Example of step 1:
    my %new_pass; while (<F1>) { chomp; my @f = split(':', $_); $new_pass{$f[0]} = $f[2]; }
    Example of step 2:
    while (<F2>) { chomp; my @f = split(':', $_); if (exists $new_pass[$f[0]]) { $f[1] = $new_pass[$f[0]]; } print F3 join(':', @f), "\n"; }
Re: Input Output file
by apl (Monsignor) on Apr 18, 2008 at 19:24 UTC
    Show us what you've written so far, and we'll help you with any problems you've encountered.

    Revised: Here's a clue. Take a look at merge files by column (revisted)