Subject: | read_text has strange side effect |
Now this is weird: We recently replaced File::Slurp with File::Slurper, and have since seen strange behaviour in code that is nowhere related to the slurping or the slurped content.
This gist demonstrates the side effect:
<https://gist.github.com/mephinet/44bf611fee31f15c6811514497b12a7b>
In test.pl, read_text is called with encoding cp1252. Afterwards, a constant string is written to a file, using utf-8 encoding. Please note that the result of read_text is completely ignored.
What happens is this:
Use of uninitialized value in subroutine entry at ./test.pl line 11.
Close with partial character at ./test.pl line 11.
Use of uninitialized value in subroutine entry at ./test.pl line 11.
Close with partial character at ./test.pl line 11.
Use of uninitialized value in subroutine entry at ./test.pl line 11.
When you comment out the call to read_text, the warnings disappear.
Seen on Gentoo Linux, RHEL5 and RHEL6 with Perl 5.20.2.
PerlIO::utf8_strict is available on all the machines (and maybe it's the one to blame?).