120 :
39:
open I,"s.txt";while(<I>){chop;$m.=$_;$w=length;$h++;}$p=index $m,'P';$m=~s|P|.|
;@b=(0,0,$w,0,-1,0,1,0,-$w,0);while($m=~/\$/){$t=$m;substr $t,$p,1,'P';for(1..$h
){print substr($t,0,$w,"")."\n";}print"\n";$v=$b[<STDIN>];$d=$p+$v;$c=substr $m,
$d,1;if($c eq'#'){next;}if($c eq'$'){$c=substr $m,$d+$v,1;if($c =~/#|\$/){next;}
substr $m,$d,1,".";substr $m,$d+$v,1,$c eq'_'?'#':'$';}$p=$d;}
よし、修正(汗)。