Perl::...andles(3pm)
π 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 AND LICENSE π
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::Criticbareword::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
- debian trixie: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- ubuntu resolute: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- ubuntu stonking: libperl-critic-community-perl 1.0.4-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms