in reply to Malformed UTF-8 character Error

UPDATE: I'd really just be interested in skipping line if it is not UTF-8, or not dealing with these lines at all.

Do you realize that you'd be skipping all four lines you posted since none are valid UTF-8?

It's easy to do:

use strict; use warnings; use open ':std', ':locale'; use Encode qw( ); my $log = 'log'; open(my $fh, '<:raw:perlio', $log) or die("Can't open log file \"$log\": $!\n"); while (<$fh>) { s/\r?\n\z//; my $data = (split(/ /, $_, 4))[3]; my ($text) = eval { decode("UTF-8", $data, Encode::FB_CROAK) } or next; print($text); }