Hi Perlmongers
Can anybody assist in this issue ?
I have two input files which I merge into a third file and discard the input files
The format of the two input files was
word decimal word decimal word decimal
The code I have does this

open F1,"F1.dat" or die "Can't open F1.dat: $!\n"; open F2,"F2.dat" or die "Can't open F2.dat: $!\n"; my (%hash1,%hash2); while (<F1>) { /(\w*) (\d*)/ ; $hash1{$1} = $2 ; } close F1; while (<F2>) { /(\w*) (\d*)/ ; $hash2{$1} = $2 ; } close F2; open MERGED,">merge.dat" or die "Can't open merge.dat:$!\n"; foreach (sort keys %hash2) { if (defined($hash1{$_})) { print MERGED "$_ $hash1{$_}\n" ; } else { print MERGED "$_ $hash2{$_}\n" ; } } close MERGED;
This works fine. However the format of the input files has now changed so that there are extra words i.e.
word decimal word....
The first two fields of each record will always be of the format "word decimal", but there could be an indeterminent number of words after the decimal.
I'm unsure how to adopt the code to handle the writing of field3 onwards to the merged file
Any thoughts welcome

In reply to file merge problem by Anonymous Monk

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.