9行、おやすみなさい

$w='#';$d='.';$s=' ';$p='P';$e='E';$o=$w x10;$m=$d x8;$b="$o\n".("$w$m$w\n" x8)
."$o\n";$y=$c=0;$l=12;$k=19;while($b=~/[$d]+/){t($l,$p);t($k,$e);print$b."YOU:".
"$y\nCOM:$c\n";t($l,$s);t($k,$s);chop($m=<>);$l+=u(--$l)eq$w if$m==1;$l+=$l<87?
11:0if$m==2;$l-=$l>19?11:0if$m==3;$l-=u(++$l)eq$w if$m==4;exit if$m eq'e';$i=u(
$l);$y++if$i eq$d;exit if$i eq$e;if(int rand 4!=3){if(u($k-1)eq$d){$k--;}elsif(u
($k+1)eq$d){$k++;}elsif(u($k-11)eq$d){$k-=11;}elsif(u($k+11)eq$d){$k+=11;}}else{
$m=int rand 6;$k-=u(++$k)eq$w?2:0if$m==0;$k+=$k<20?11:-11if$m==1;$k+=$k>85?-11:
11if$m==2||$m==3;$k+=u(--$k)eq$w?2:0if$m>=4;}$i=u($k);$c++if$i eq$d;exit if$i eq
$p;}sub u{substr$b,$_[0],1;}sub t{substr$b,$_[0],1,$_[1]}