What more info do we need?
With the information you've provided so far, I just can't help. I am pretty sure that none of the lines you've shown so far can throw a "Malformed UTF-8 character". Instead, two of the lines are syntax errors. Please take care when providing code samples that they actually demonstrate your point.
You also haven't quoted the exact error message, which might contain more information about the offending character, as in the following examples:
Malformed UTF-8 character: \xa4 (unexpected continuation byte 0xa4, wi
+th no preceding start byte) at /tmp/a.pl line 3
Malformed UTF-8 character: \xe4\x22\x20 (unexpected non-continuation b
+yte 0x22, immediately after start byte 0xe4; need 3 bytes, got 1) at
+/tmp/a.pl line 7.
Finally, you haven't answered my question about your decoding routine. Perl complains about malformed UTF-8 characters when you feed it a string which you declare as UTF-8 but it isn't, but I can't see any of this in your code.