<>; while(<>){ $_=<>; if(s/.*\K[h?][e?][l?][l?][o?][w?][o?][r?][l?][d?]/helloworld/){ y/?/a/; }else{ $_="-1\n"; } print; }