You want to use the Encode module, which is a core part of Perl since 5.8. The best way of doing it would be to use it like this:
open(my $fh, "<:encoding(utf-8)", $myfile); # read from $fh here close($fh);
That will read from $myfile as if it's a UTF-8 file. If the input file is not, in actual fact, UTF-8, then it will spew errors along the lines of 'utf8 "\xA1" does not map to Unicode', and your input text will have a stringified "\xA1" (or whatever the character was) in the text where the invalid character appeared. In this way, your scalar will be guaranteed to be valid UTF-8.
There are other things you can do with Encode; I've used it a lot. If you need help on how to do anything with it, let me know - character encodings are something of a specialty for me.
Re: no apologies needed, thank you for pointing that out
open(my $fh, "<:encoding(utf-8)", $myfile);
# read from $fh here
close($fh);
That will read from $myfile as if it's a UTF-8 file. If the input file is not, in actual fact, UTF-8, then it will spew errors along the lines of 'utf8 "\xA1" does not map to Unicode', and your input text will have a stringified "\xA1" (or whatever the character was) in the text where the invalid character appeared. In this way, your scalar will be guaranteed to be valid UTF-8.
There are other things you can do with Encode; I've used it a lot. If you need help on how to do anything with it, let me know - character encodings are something of a specialty for me.
[edit: Fixing bad text.]