Hi everyone--
Pardon my "newbieness"--this question seems like it should be pretty easily solved, but I can't seem to think about it right. I have a file that contains two columns: a name column and a column of numbers. I also have an array that contains a list of names. The array contains almost all of the names in the file, as well as many others that are not in the file. Here's what I mean exactly:
FILE ARRAY
name1 4.5 name1
name3 3.4 name2
name5 6.5 name3
name4 -7.9 name4
name6 3.2 name5
And I want to end up with an array of numbers, sorted by the names in the array. And, where there is a null value, I want 999 entered. Thus, I want the resulting array to be something like this:
4.5
999
3.4
-7.9
999
I'm just having a bit of trouble doing the correct (and time-efficient) iteration. The columns and arrays are about 10,000 elements long. Thanks,
Evan
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.