I thought to play with the $header, but would not it cause problems? If I remove it, then the whole script would treat it just another key-value pair, and since it does not have a match on the second file, it will be dropped.
Yes, you are right! However, the (real) second file does not include any column titles at all!
file 1:
id val1 val2 val3
452 sdfdf sfgfdg asfa
154 afa afafe rghreh
161 aafa gte fdhd
file 2: (one empty line - no header)
452 kmfgkmg
213 adfadfa
997 afdafa
161 adaadaada
so the result file should capture the column titles from the first file while the second file acts only as to make possible to match and then capture the relevant new value.
resulting file:
id val1 val2 val3
452 sdfdf sfgfdg asfa kmfgkmg
161 aafa gte fdhd adaadaada
while of course i can introduce a header to the second file as such id val4
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.