Hi all,
This is really not all that clever, but at least it's 1 step further than being scripted.
$p='$_=$/rekcah lrep rehtona tsuj select$q,$q,$q,print(chop)/10 while$_'; $SIG{__WARN__}=sub{$e=$_[0]=~/line/?$_[0]:$@;print"$e$/FIXING$/$/";$c= +0; $n="";$e=~/line (\d+)/s;$l=$1;if($e=~/Bare/s){for(split$/,$p){if(++$c= +=$ l){s#=([^"]+)$#="$1"#};$n.=$_.$/}$p=$n;}elsif($e=~/tax er/s){$c=$p=~ s#([^;])\n#$1;\n#gs}sleep 1;&r if$c};&r;sub r{$|=print$p.$/x2;eval$p}
Enjoy!
Alex
p.s. It doesn't use escape codes! so it should work on windows as well!

Replies are listed 'Best First'.
Re: self repairing code
by Abigail-II (Bishop) on Feb 24, 2004 at 13:12 UTC
    That's a bit like one of my Japhs:
    BEGIN{$SIG{__WARN__}=sub{$_=pop;y-_- -;print/".*(.)"/; truncate$0,-1+-s$0;exec$0;}}//rekcaH_lreP_rehtona_tsuJ
    Or:
    BEGIN{$|=$SIG{__WARN__}=sub{$_=$_[0];y-_- -;print/(.)"$/;seek _,-open( +_ ,"+<$0"),2;truncate _,tell _;close _;exec$0}}//rekcaH_lreP_rehtona_tsu +J
    (for both, make sure there are no trailing newlines).

    Note that in my versions the actual source code (that is, the characters in the file) is corrected. Run it once, and you see the familiar line - run it a second time, and nothing happens: the code has been corrected!

    Abigail

      sorry mate, i certainly didn't mean to tread on your code.
      al