As irah said, processing the document line by line could be a good idea. But there's probably no problem with doing otherwise.
A Perl "trick" you may find useful is changing your script definition of what a line is, for exemple you could read your input file paragraph by paragraph instead of line by line, if a single line isn't enough information for you to work with. Check the documentation on $/ for that. For example, if your paragraphs are separated by a ----- line you could write :
{
local $/ = "\n-----\n"; # We make sure to localize the reading behav
+iour to the inner block
while(my $paragraph = <$yourInputFile>)
{
# code that processes the data
}
} # At this point we go back to a normal reading behaviour