Reputation: 353
What I am actually trying to do is, extract range of lines from a text file and print the ranges in another file. The start range of strings are stored in @secarr and corresponding end range of strings are stored in @exarr. The problem now I am facing is that $secarr[4] and $exarr[4] range is found near the EOF and hence the output file ends till there. But $secarr[5] and $exarr[5] and many other ranges are present before $secarr[4] and $exarr[4] range.
Please suggest me a way out.
Thanks in advance, Faez
Upvotes: 0
Views: 111
Reputation: 3508
You may want to have a look at Tie::File, which gives you a simple interface to the records of your file.
Upvotes: 0
Reputation: 241998
The simple approach is to reopen the file for each range. You can also try:
my @array = <$IN>;
). For each range, you just print the array slice.Upvotes: 3