![]() |
|
Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Why is using binmode on a file handle 77 times slower than just closing it and re-opening?by choroba (Cardinal) |
on Nov 25, 2024 at 08:41 UTC ( [id://11162874]=note: print w/replies, xml ) | Need Help?? |
The problem is binmode doesn't change the layer of the filehandle, it adds a new layer. Try appending the following line to your test: And then try to count how many times the string encoding(utf-8-strict)utf8repeats. In my case, it was 922 ×
To fix that, clear the layers before applying new ones by starting with :raw: The result becomes agreeable: And the warning now shows a pretty low number. Updated: Show how to count the repeated layers. Update 2: On MSWin, you might need to add :crlf after :raw if needed, too.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
In Section
Seekers of Perl Wisdom
|
|