$_="- -"; for$i(1..3){$_=join' 'x length,($_)x 2} for$i(0..3){ $n=3**$i; unshift@_,s/- {1,$n}(?=-)/'-'x length$&/ger.$/ } print@_,$_