in reply to help to write perl code
Your program gets stuck in the $sub_line=<IN> loop even after finding the INIT_VAL tag, add last; to break out.
To see this add $line_count to this line print "The line no is $. looking for $line_count\n";