in reply to capturing blocks of data

If you're using "HOSTNAME" in your post as a sort of "placeholder" for a wide range of different strings (like "abc.def.com", "college.univ.edu", etc), then some of the replies above will be off the mark.

On the other hand, if the ">>" that precedes the first occurrence of each HOSTNAME string is reliable, and if that pattern occurs only as the initial two characters of a new record, then just set perl's record separator variable ($/) to ">>". That way, the standard while loop with the diamond operator will read one full record at a time.