<>; while(<>){ $_=<>; if(/helloworld/){ }elsif(/.*\K[h?][e?][l?][l?][o?][w?][o?][r?][l?][d?]/){ @a=(); $a=$_; $p=@-[0]; for$i($p-10..$p){ if($i>=0){ $_=$a; pos=$i; if(s/\G[h?][e?][l?][l?][o?][w?][o?][r?][l?][d?]/helloworld/){ push@a,$_; } } } ($_)=sort@a; }else{ $_="-1\n"; } y/?/a/; print; }