in reply to
Re: Reading particular line which repeats itself many times in text
in thread Reading particular line which repeats itself many times in text
Thanks for your replies. I have solved the problem by putting together the concepts of non greedy quantifier(?) and storing the whole file (using File::Slurp) in a scalar variable. Here is the code.
local $/ = undef;
open FILE, "my_text.txt" or die "Couldn't open file: $!";
$string = <FILE>;
if ($string=~/BEGIN hi(.*?)END/s)