Link to home
Start Free TrialLog in
Avatar of tian
tian

asked on

locate an entry and related information in the file

Hello,
Does any one have an good idea  to implement following question in perl effectively.
suppose there is a file the format is:

metrics        range

entry1           0-12
entry2           0-56
entry3           0.2-13.4
....
....

when the program gets an entry name and its value from user(e.g. "entry2   24"),it can locate this entry and its range in the file.Then check if the given value is within range. and report "success" or "fail" to the user.
Avatar of alamo
alamo

Before I give you some code, would you please confirm that this is not an assignment for any class? Posting class assignments is against EE rules.

(I haven't heard of any classes giving assignments in perl, but the nature of the problem and the way it's phrased is very assignment-like, and I am just making sure).

Avatar of tian

ASKER

It's difinitely not.
Avatar of tian

ASKER

It's difinitely not. In fact, I already implemented it:
read file one line at one time,then use "split" to parse it and commpare corresponding items with user input.....  
ASKER CERTIFIED SOLUTION
Avatar of alamo
alamo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tian

ASKER

thank you very much.
 But how about if metric user given is just part of a compound metric in the file.
for example:

metric_name       range
-----------------------------------
m1                       1~12
m3+m4                23~34
m7                    45~23
.......
what the user input is " (m3  3),(m1 19), (m4 23)..." and the program can make a report indicate the "false" or true" for each metric entry in the file
Avatar of tian

ASKER

Sould I post modified question again?
I just now saw your comments... yes, the new question is a different than this one because the compound metrics means you have to save the inputs and loop through the metrics, calculating each one. All the code changes.

I can't take a look at it quite at this moment unfortunately, if the new question is still unanswered later I will answer it, in any event good luck!