It would be nice if you could show what code you have attempted and tell us in which way it fails to meet your requirement, so that we could help overcoming specific difficulties, rather than expecting us monks writing the full code for you, which would be of very little pedagogical benefit for you.
Here, the basic idea should be to read the file line by line, to set up a flag when you meet the x start criteria and set if off when you find the y end criteria. And of course to print out the lines when the flag is set.
So the pseudo-code could be something like this:
There are many ways of translating this into actual Perl code, and there are shortcuts which could make the actual Perl code shorter, but there are also a few more things to be thought about in actual code, such as dealing with end-of-line characters, etc.flag = false; while (there are lines in the file) { if (line equals "x") { flag = true; } elsif (line equals "y") { flag = false; } else { if (flag) { print line; } } }
Please try to convert this pseudo-code into Perl and tell us where you're encountering problems.
In reply to Re: extract data from text file
by Laurent_R
in thread extract data from text file
by ikhan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |