"be consistent" | |
PerlMonks |
Re^3: Potential bug in chrby ikegami (Patriarch) |
on Feb 05, 2018 at 01:31 UTC ( [id://1208452]=note: print w/replies, xml ) | Need Help?? |
makes far more sense than
It binmodes STDIN, STDOUT and STDERR (with the safer :encoding(UTF-8)). It also sets the default encoding for the instances of open in the scope (making the :encoding('UTF-8') redundant in the open).
Which is irrelevant to the question at hand. The first print worked because the string contained non-bytes (chars outside of 0..255), which can't be printed without encoding. perl guessed that you meant to encode them using UTF-8 (and warns you about this ("Wide character in...")). perl had no way of knowing the second print was wrong because it only contained bytes (chars in 0..255), so it printed the string unaltered.
In Section
Seekers of Perl Wisdom
|
|