$_=<>;\x0d {s/(\[)(\d+)(\]B@)(\D+)(\d+)(:[>})])/$4."."x(2+length$5).$1.($2+$5).$3/e&&redo}\x0d {s/(\[)(\d+)(\]B@)(\D+)(\[)(\d+)(\]B@)/$4.","x(4+length$6).$1.($2+$6).$3/e&&redo}\x0d print
Note that non-ascii characters in the above source code will be escaped (such as \x9f).