Please write me a program for the same. It will help.
Please clean my gutters for me. It will also help.
Seriously. Show some code you've tried if you want guidance or offer to pay someone privately if all you want is code written. Some relevant documentation you might read to get started on your own includes the top stuff here perlre and open.
| [reply] |
On the off-chance that this is simply a communications problem, and what you really meant was "can you explain what I'd need to do to solve this problem" (though it smells heavily of a take-home interview question...). I am only going to very basically outline a possible solution.
- Slurp the whole file in at once. (hint: $/).
- Use a pattern match that captures the text between the start and end markers. You'll want the /sm modifiers on the match to make sure you cross line boundaries. (Hint: \t is a tab.)
- Print the captured text.
I'd estimate this to be a very small program. If you're over 20 lines you're overthinking it.
If what I've said here isn't helpful, you really need to settle in with a good Perl tutorial and learn some of this stuff. I recommend Learning Perl as a good start, or here: http://www.perl.com/pub/a/2000/10/begperl1.html.
I am concerned that you're just hoping for a solution. If you read around on Perlmonks you'll find that we seldom just write someone a program. If they post at least a "Here's the code I tried, but this part doesn't work", yes, very often there'll be a "here's a way to solve that" with a partial or even complete solution. But a plain old "write this for me" smacks of "I can't be bothered to do this myself, I'll take advantage of these people's willingness to write code for free" at best, and seems dishonest at worst - be sure that if you "solve" a problem by getting an answer from Perlmonks, sooner or later it will catch up with you. Managers know how to do web searches too, and the good ones will. (A quick search on strings from your example file input turns up this node, for instance.) | [reply] |
prasanthpronda:
- - : for failing to read-and-heed the introductory info about the Monastery...or even the instructions on the page where you entered this plea. Try doing so now:
Nonetheless, welcome. We really do provide help, and gladly, when the post contains something other than "Please do it for me, for free." | [reply] |
Assuming the blocks can't be nested,
perl -ln0777e'print /start:(.*?)end:/gs' input.txt
| [reply] [d/l] |