I guess I'm not making much sense due to rushing. But the idea is, that I want to populate a new array from the result of grepping another array based on the contents of a given field.
I'm not sure if using grep is a better choice than stepping thru the old array using a loop(foreach, etc) and splitting the individual records using split and then pushing the matching records into the new array if the given field matches what I'm looking for. But it seems more succinct.
Details:
I have a file that has 21 fields and 100's of records. I've sucked that file into an array (@recs), and I want any records(elements) from the @recs array in a new array(@goodrecs) that have a given email address in the 4th field. Each record(element) in the array @recs is ":" delimited. You could think of it like reading a passwd file into an array:
open(FH, "<passwd") or die $;
my @recs = <FH>;
etc....
so what I'd like to do is something like:
my @goodrecs = grep(/^.*?:{3}foo@foobar.com/, @recs);
This does not work. But That's the idea.
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.