in reply to Malformed UTF-8 character Error

Rather than skipping whole lines because they contain non-character (or mixed encoding) data -- which might be most or all of the lines -- you could just "neutralize" the non-character content, by converting it to something innocuous. Here's an example, adopting the "open" method shown above by ikegami:
use strict; use warnings; my $log = shift # let's put the log file name in @ARGV or die "Usage: $0 name_of_input_file\n"; open(my $fh, '<:raw:perlio', $log) or die("Can't open input file \"$log\": $!\n"); while (<$fh>) { tr/\x09\x0a\x0d -~/./c; print; }
That just converts all non-visible, non-ascii bytes to "." -- which allows you to see where the non-printable stuff is, while leaving the printable ascii stuff legible, with no worries about character encoding errors.