Perl::...andles(3pm)

πŸ“¦
version 1.0.4 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Perl::Critic::Policy::Community::BarewordFilehandles β€” bestie, this is the policy that says don't use bareword filehandles other than built-ins. That's it. That's the whole vibe. She's a 3pm manual page, she's here to keep your open() calls looking cute and scoped. πŸŽ€


✨ DESCRIPTION ✨

okay so. bareword filehandles are allowed in open() as a legacy feature (yes, really, it's giving ancient Perl energy πŸ’€), but the way they work is that they quietly grab a global package variable. global. in the year of our lord. not the move, bestie. πŸ™ˆ

instead, use a lexical variable with my so that:

  • the filehandle is scoped to the current block πŸ‘‘
  • it gets automatically closed when it goes out of scope πŸ¦‹

Built-in bareword filehandles like STDOUT and DATA? Those are totally ok. iconic behavior, no notes. πŸ’…

open FH, '<', $filename;     # not ok
open my $fh, '<', $filename; # ok

ngl this policy is similar to the core policy Perl::Critic::Policy::InputOutput::ProhibitBarewordFileHandles, but she's the chiller older sister: she allows more combinations of built-in bareword handles and filehandle-opening functions such as pipe and socketpair. 🫢


🌸 AFFILIATION 🌸

This policy is part of Perl::Critic::Community. found family fr fr. πŸ’œ


πŸŽ€ CONFIGURATION πŸŽ€

This policy is not configurable except for the standard options. no knobs to twiddle, she comes as she is, main character energy ⭐


πŸ‘‘ AUTHOR πŸ‘‘

Dan Book, dbook@cpan.org πŸ’Œ


Copyright 2015, Dan Book.

This library is free software; you may redistribute it and/or modify it under the terms of the Artistic License version 2.0. slay, legally. ✨


πŸ¦‹ SEE ALSO πŸ¦‹

  • Perl::Critic
  • bareword::filehandles

and that's the whole page, bestie!! this one was rendered from the User Contributed Perl Documentation for perl v5.40.1, dated 2025-03-22. go forth and my your filehandles, ily, bye πŸ’–πŸ’…πŸŽ€

πŸ“¦ where this page comes from