Tuesday, 17 September 2013

How to read in multiple lines into one array until the next line fits certain criteria in Perl?

How to read in multiple lines into one array until the next line fits
certain criteria in Perl?

If I want to read multiple lines with same elements into one array until
reaching the next line with a different element. These elements have
already been sorted so they are in the lines next to each other. For
example:
1_1111 1234
1_1111 2234
1_1111 3234
1_1112 4234
1_1112 5234
1_1112 6234
1_1112 7234
1_1113 8234
1_1113 9234
I want to read the first three lines with same element 1_1111 into one
array, process it, then read the next few lines with the same element
1_1112

No comments:

Post a Comment