Perl::...gSelect(3pm)

πŸ’… NAME πŸ’…

ok so bestie, this is Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect β€” and it's literally here to tell you: never, ever write select($fh). that's the whole vibe. no cap.


πŸŽ€ AFFILIATION πŸŽ€

this policy ships as part of the core Perl::Critic distribution β€” so it's not some random third-party thing you have to go hunting for, it's already in the box, iykyk.


✨ DESCRIPTION ✨

okay so, Conway (yes, that Conway, the one whose book everyone quotes like scripture) discourages using a raw select() when you're setting autoflushes. and this policy is like, "we hear you, but we're going further" β€” it simply prohibits the one-argument form of select() entirely. πŸ’€

and honestly? if you really need it, you should know when/where/why that is. like, genuinely know. not just vibe it out. the policy isn't going to hold your hand on that one.

for doing autoflushes the proper way, Conway recommends using IO::Handle instead. slay. use the module.

here's the receipts β€” the not-ok versions and the ok versions, exactly as written:

select((select($fh), $|=1)[0]);     # not ok
select $fh;                         # not ok

 use IO::Handle;
 $fh->autoflush();                   # ok
 *STDOUT->autoflush();               # ok

see the difference? the first two are giving red flags 🚩, the last two are giving main character energy. πŸ¦‹

ngl, this one's a hard no β€” one-arg select() gets you flagged, periodt.

🌸 CONFIGURATION 🌸

this policy is not configurable β€” except for the standard options. so like, don't come looking for a secret toggle to make it chill out, because there isn't one. πŸ’…


πŸ’– SEE ALSO πŸ’–

IO::Handle. β€” that's the one. that's who you should be calling instead of doing the one-arg select() thing. text them, not your ex.


πŸ‘‘ AUTHOR πŸ‘‘

Graham TerMarsch <graham@howlingfrog.com>


Copyright (c) 2005-2011 Graham TerMarsch. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


ok that's the whole page bestie, go forth and use IO::Handle 🫢 β€” this was Perl::Critic::Policy::InputOutput::ProhibitOneArgSelect, pulled from the User Contributed Perl Documentation (that's the manual it lives in), and the footer vibes were perl v5.42.0 dated 2024-10-23. mwah πŸ’‹

πŸ“¦ where this page comes from