[EMAIL PROTECTED] wrote: > > I am a beginner in Perl an I have a trouble, I am sure you are going to > help me. > > Suppose I have a file with, for example, 10 lines, every one composed by > a inferior value and a superior value and a string. Every inferior value > is equal to superior value of the before line. On the other hand, I have > other file with, for example, 1000 lines with a only column of values and > I want to create another column here with the value of the string if the > value of the column is between two values (inferior-superior) of the same > line in the first file, I mean, it would be several consecutive lines > with the value of the string of the line 1 of first file, after, several > consecutive lines with the value of the string of the line 2, and so on. > > How can I do that?, I open the files but I am not sure how to do it.
May we see a sample of your data? Your first file sounds like: 1 5 String1 5 8 String2 8 16 String3 16 23 String4 : while your second file is 2 4 6 8 10 12 14 16 : And you want 2 String1 4 String1 6 String2 8 String3 10 String3 12 String4 14 String3 16 String4 : Is that right? A couple of questions: In the case of '8' and '16' above the value falls within two ranges in the first file. Which wstring should be used? What is the possible range of values in the second file1? If there are only, say, a few hundred values, then you could set up an array to look up the values from the second file, looking like this: my @lookup = qw/ String1 String1 String1 String1 String2 String2 String2 String3 String3 String3 String3 String3 String3 String3 String3 String4 String4 String4 String4 String4 String4 String4 String4 /; But this isn't practical if the range is large. Let us know, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]