http://www.perlmonks.org?node_id=293997


in reply to use of $_ is destroying @database ... why?

While I haven't tested this in detail, it would seem to me that your usage of while (<T>) in load_tbls is clobbering $_, which is aliased to an entry in @database. Thus, when the while loop exits, $_ is undefined (the exit condition).