ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
basically what i need to do is get that box in between the two blah blah blah lines.
I cant think of an elegant way to accomplish this..
can anyone give me a hand?
thanks
the actual format is a bit more complicated than i simplified above, its actually more like a block of text, then the box then another block of text. this repeats thoughout the file.
So just to see if there is a better way of doing it, what i did was to create 3 arrays, BEGIN, BOX, END, I just did a push(@ARRAY, "$"); based on whether the line came from the first block of text or the box, or the end block of text. once i hit the beginning of the first block again i would print out the arrays in the revised order, and then set them to ''.
I just realized while i was typing this, that i'm going to have to add to it, because i will lose the last group because it will hit EOF without seeing the beginning of a new BEGIN block of text.
Is the way i did it fine, or is there a more elegant way of doing it?
thanks
Help us to help you. You gave a sample input file (that's good) and some words (also good). Construct a sample output file which corresponds to your sample input and post it here. With a "Before and After" example we can better understand your needs and also judge if our proposed solution fits those needs.
Better still, compose a verbal description of the layout. Use terms that give absolute and relative orientation. For instance, "A" always starts/ends/contains "XX" or "YY", and the sections to extract start "n" lines following "A" and end with "ZZ". Once you've done this, the code will almost write itself in many programming languages. A sample of the input data, and the desired output is also very helpful; like painting a picture. Most often, there is a very large universe of algorithms that will get you from the single example input to the single example output, but very few algorithms that will work in all cases.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.