in reply to Re^2: It works!
in thread Input Record Separator WON'T WORK!

The input would need to be processed in order (char by char, then token by token). Using a parser generator (e.g. Parse::RecDescent and a good book on parsing) will help a lot, while still leaving much to learn.