I came up with similar to huck
#!/usr/bin/perl use warnings; use strict; my $file1=<<END; "A123","valueA1","valueB1" "B234","valueA2","valueB2" "C345","valueA3","valueB3" "D456","valueA4","valueB4" "E567","valueA5","valueB5" "F678","valueA6","valueB6" END my $file2=<<END; "C345","valueX1","valueY1" "D456","valueX2","valueY2" END my %hash; # read file1 into a memory hash table open (FILE1, '<', \$file1) or die "$!"; while (my $line = <FILE1>) { chomp $line; my ($key,@vals) = split ',',$line; $hash{$key} = [@vals]; } # process file2, modify the memory hash table open (FILE2, '<', \$file2) or die "$!"; while (my $line = <FILE2>) { chomp $line; my ($key,$val1) = split ',',$line; $hash{$key}[0] = $val1 if $hash{$key}; } # dump the hash table foreach my $key (sort keys %hash) { print "$key,", join(",",@{$hash{$key}}),"\n"; } __END__ Prints: "A123","valueA1","valueB1" "B234","valueA2","valueB2" "C345","valueX1","valueB3" "D456","valueX2","valueB4" "E567","valueA5","valueB5" "F678","valueA6","valueB6"

In reply to Re: Replace value in the text file by Marshall
in thread Replace value in the text file by mhoang

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.