Hello community,
I am running a test which prints the following output:
Consider the following output format:
-date-
-version-
-more-info-can-be-more-than-one-line-
------------------------------------------------------------------
status id -more-parameters- name
------------------------------------------------------------------
... .... ... ....
------------------------------------------------------------------
Notice that its kind of a table with information.An example for this table:
date:17/4/2000
version: 4.1.0
-more info-
-more info-
------------------------------------------------------------------
Status id not important info (two columns) name
-----------------------------------------------------------------
Run 1234 @ ... foo1
Wait 54123 @ ... foo2
-----------------------------------------------------------------
I would like to write the two following functions which get 'id' number as argument:
1. If I have the current id "1220" argument, I would like to get an array of (id,status,name) of the line with the next minimal id (or just scalars, doesn't matter). In the above example, it would be (1234,Run,foo1) because there is no smaller number than 1234 and larger than 1220. If it doesn't have lines at all, it will be undefined.
2. (first way is more important to me) I would like to get a hash so the keys are id and the values are their status. maybe in this way it will be easier to get the first thing.
What I thought to do - I tried to combine regex and loops to iterate over the output and get the information I need, although I failed. I think regex are the key to solve this problem.
Looking for the cleanest way possible.
Hope that my question is clear (if not, I would glad to specify more).
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.