It looks like the # character is being interpreted as a start-comment character, which makes it very confusing as to what perl actually things this code is.
I'd recommend storing it internally as something else, and only converting it to a # in printmap. The fewer \# you have, the better.
-- Kirby, WhitePages.com
Comment on Re: Writing a random dungeon generator in perl.