|There's more than one way to do things|
Re^3: Reading file into a hash (last record problem)by LanX (Cardinal)
|on May 28, 2014 at 15:14 UTC||Need Help??|
Thats a very common problem, you are trying to add a record only when the successor is to be parsed, but the last record has no successor (sic ;)!
Most people try to solve by repeating code to add the last record after the loop.
But it's much cleaner this way (avoiding a posteriori state logic)
( addicted to the Perl Programming Language)
a *general pattern* to solve such problems while staying DRY is to use references
like this you don't need to repeat the path of a deeply nested data structure, which might vary in multiple dimensions
updateadded some explanation