I never knew you could use bitmasks to do something neat like this, I wish I knew that sooner.
they're pretty useful, I've been using them for pretty much everything map generating related
they work well with road/maze generators because you can do a switch statement to put the correct road tile down
and it's easy to generate the bitmasks in the first place (linking two nodes is just %westNode |= $paths[east]; %eastNode |= $paths[west];)