I need a little jumpstart here - kind of stuck at the moment. Maybe there are a couple modules you can suggest? I'm familiar with List::Compare and Array::Compare.
Problem:
File 1 format: 9-digit-number year string
File 2 format: 9-digit-number year
So, file 1 may look like:
123456789 1900 foobar
123456789 1901 fooba
123456788 2000 foob
(notice the possible repetition of the 9-digit-number)
file 2 looks similar, minus the string.
What I need is to compare the 9 digit number+year combination between the two files by running through file 1 and comparing against file 2. If file 2 does not have a match for the line in file 1, spit out the line grabbed from file 1 (INCLUDING the string) into a separate file.
Maybe I'm making this too hard for myself, but so far I figure something like:
open all files
grab all lines from file 1 - split each line into 3 strings( $number,
+$year, $string)
concatenate $number.$year into one $searchvalue
make hash with keys of $searchvalue and values of $string
populate array1 with these $searchvalues
grab all lines from file 2 into array2
compare array1 to array2
where value from array1 doesn't find a match in file2, print hash valu
+e with the key of $searchvalue to file results
this close? any tips, suggestions? Thanks!
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.