next unless /\s/; #### next if $_ eq substr "' . (quotemeta $password) . '", 0, length; #### [[... beginning of the code as above...]] print ' use warnings; use strict; use List::Util qw(min); select STDOUT; $| = 1; my $chr; $_ = ""; CHAR: while (defined ($chr = getc DATA)) { $_ .= $chr; foreach my $n (1..min ' . (length $password) . ', length) { next CHAR if substr ("' . (quotemeta $password) . '", 0, $n) eq substr ($_, (length)-$n, $n); } s/' . (quotemeta $password) . '/removed/ig; print; $_ = ""; } print; __DATA__ '; [[... the rest of the code is as above...]]