In your get_data() sub, your while loop takes up where the other one left off. The first thing it does is read in a line and place it in $_, but since you already read the author line, you lose it.
You could get around that by changing your loop in the get_data() sub to do { . . . } while ( <FH> ); instead. That wouldn't read in the next line until you had processed the first line.
If you records are always separated by a blank line, though, I'd suggesting reading each record at a time by putting perl in "paragraph" mode. You do that by setting $/ = "";. (See the entry for the $/ var in perldoc perlvar for more information.) Then, I'd parse each record into a hash. That would give you much more flexibility.
By the way, do you have any control over the data? Because, if you do, I'd consider changing your format. Real XML would probably be better in the long run than that bizarre broken XML-ish format.
-sauoq "My two cents aren't worth a dime.";
In reply to Re: Searching data file
by sauoq
in thread Searching data file
by parisa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |