does what you ask for. But that sure doesn't seem likely to be the answer your teacher wants. Until you can explain clearly what it is that you need to do you will not be able to write a program to do it. First step: describe the problem.

I am going to hazard a couple of guesses here. First guess, the data you want to print between "begin" and "end process" might not be a simple as you describe and might not be easily identified by a regex pattern. Second guess, from your code it looks like you might be having a stab at a simple state engine. Looking at the desired output I'm not sure why you are also trying to detect the "process ..." line.

In the code below I read the DATA filehandle a line at a time and use the variable $printIt to keep track of the state that determines whether we print a line or not. Set to 0 (false) initially, it is set to 1 (true) when we find a line just containing begin and reset to false when we get end process. I have amended your data, making the desired output lines more random (if you ignore the asterisks I've put in to make them stand out :-) and adding some more lines to illustrate the importance of anchoring your patterns (have a look at perlretut and perlre). I make three passes over the data (have a look at readline, tell and seek), firstly processing with the pattern detecting "begin" not anchored at all, secondly with it just anchored to the beginning of the string and finally anchored at both ends.

Here is the output. Note how the lines printed are whittled down as we add the anchors into the regular expression that detects the begin line.

==================================================
because we do not want this line
or this
start
*** This is a line we want ***
*** So is this ***
hkl
process khfk
shoot
hooter
*** Another desired piece of data ***
==================================================
*** This is a line we want ***
*** So is this ***
hkl
process khfk
shoot
hooter
*** Another desired piece of data ***
==================================================
*** This is a line we want ***
*** So is this ***
*** Another desired piece of data ***
==================================================

When putting a smiley right before a closing parenthesis, do you:

Use two parentheses: (Like this: :) )
Use one parenthesis: (Like this: :)
Reverse direction of the smiley: (Like this: (: )
Use angle/square brackets instead of parentheses
Use C-style commenting to set the smiley off from the closing parenthesis
Make the smiley a dunce: (:>
I disapprove of emoticons
Other