On 14 March 2015 at 22:38, Manfred Lotz <manfred.l...@arcor.de> wrote:
> following error message which is fine. Sorry for being pedantic, but I think you'll find that those are what we call "warnings", not "errors". Errors tend to be fatal. However, curiously, "<:utf8" 's warnings seems to be regulated by the warnings pragma. But "<:encoding(UTF-8)" is not. --- use strict; use warnings; ## make the file { open my $fh, '>', './somefile'; print $fh chr(0x90); close $fh; } ## read the file { *STDERR->print("Attempt 1\n"); open my $fh, '<:utf8', './somefile'; my $string = <$fh>; close $fh; } { *STDERR->print("Attempt 2\n"); open my $fh, '<:utf8', './somefile'; no warnings 'utf8'; my $string = <$fh>; close $fh; } { *STDERR->print("Attempt 3\n"); open my $fh, '<:encoding(UTF-8)', './somefile'; no warnings 'utf8'; my $string = <$fh>; close $fh; } --- The first and last of these warns, the middle does not. Though all of the above can be captured with local $SIG{__WARN__} = sub { printf "<%s> @ %s\n", $_[0], join q[,], caller(); }; Whether or not that is recommended is a different question. -- Kent *KENTNL* - https://metacpan.org/author/KENTNL