I see two big bugs.
- One:
You're using <DATA> in list context, which will only ever return anything(everything!) once, but you're using it in a while loop. The second loop iteration will assign an empty list to @lines, then evaluate false and leave the while loop. Just erase the while loop, and leave it's conditional as a non-loop-control statement, and this bug should be fixed.
- Two:
The last foreach is rather borked. You're trying to use strings as hash refs. You should replace @lines with @{ $vars{lines} } I think, but I can't really tell what you're doing so I'm not totally sure.
Also, are you really trying to throw away the reverse_map lines? It isn't clear. You should handle this case like the comment, if you're expecting that data and don't want it. That will make the code more clear. Also, consider starting that regex with
^\s* to speed the program up.
--
Snazzy tagline here