3 ms·
A bit off-topic, but their perl code is buggy. fork() returns undef on error, not -1. And you can use '$FH->autoflush(1)' instead of the eye-watering 'select((
by joosters 7y ago
A bit off-topic, but their perl code is buggy. fork() returns undef on error, not -1.
And you can use '$FH->autoflush(1)' instead of the eye-watering 'select((select($FH), $|=1)[0])'
- jwilk 7y agoI was going to say that you need to use the IO::Handle module to be able to use the autoflush method, but apparently this no longer necessary with modern Perl. From https://metacpan.org/pod/perl5120delta#Other-potentially-incompatible-changes https://metacpan.org/pod/perl5120delta#Other-potentially-inc... : > Filehandles are now always blessed into IO::File. > The previous behaviour was to bless Filehandles into FileHandle (an empty proxy class) if it was loaded into memory and otherwise to bless them into IO::Handle.
- jwilk 7y agoOn a second thought, this is probably the right changelog entry: https://metacpan.org/pod/perl5140delta#Filehandle-method-calls-load-IO::File-on-demand https://metacpan.org/pod/perl5140delta#Filehandle-method-cal... When a method call on a filehandle would die because the method cannot be resolved and IO::File has not been loaded, Perl now loads IO::File via require and attempts method resolution again