What I have done in the past is to store things into a variable before printing the output. If the file isn't drastically huge, this won't be a problem:
# Just a snippet -- assume variables decared, etc.
while(<FILE>) {
$out =~ s/\x1a//;
}
print $out;