sub f{print y'|' 'r;s'\\.' \\'g;s' /'/ '&&&f}sub g{print y'/\\'|'rx$n}f$_=$"x~-($n=<>/2).'/|\\'.$"x~-$n.$/;g;y'/\\'\\/';map{f;y'/' '?f|s' \\'/ \\':s' \\'/\\';f}y'|'\\'r;g;f
Note that non-ascii characters in the above source code will be escaped (such as \x9f).