in reply to I know this code could be better...

  1. As petdance pointed out, your file reading routine can be simplified:
         @lines = <NODE>; </CODE>
  2. Further, you can directly insert into a hash from your split, because in a sense a hash is just a fancy list:
         %known_files = map { my($k,$v)=split(/=/) } <LINKS>;
  3. Post-processing would allow you to figure out the 'top_level' stuff:
    foreach (keys %known_files) { if(/announcements|links|news|info/i) { $top_level{$_} = $known_files{$_}; } }
  4. When you want to print an array, you just print it. You don't need to do anything special.
    sub middle { print @lines; }