in reply to content extraction

Hmm, why do you capture patterns that you never use?

while ($content =~ /^MEDICAL HISTORY:(.+?)\n^[A-Z]/sgm) print "$1\n"; }

Also, why do you exit at the end of your script?

And you didn't even know bears could type.