Perl::...thPrint(3pm)
β¨ NAME β¨
okay so this page is the whole vibe for Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint β a User Contributed Perl Documentation situation (Perl::...thPrint(3pm), if you're clocking the header). What it wants, bestie, is for you to write print {$FH} $foo, $bar; instead of print $FH $foo, $bar;. Periodt. π
πΈ AFFILIATION πΈ
This Policy is part of the core Perl::Critic distribution. Iconic. It's already in the group chat. β¨
π¦ DESCRIPTION π¦
The print and printf functions have a unique syntax that supports an optional file handle argument. Conway suggests wrapping this argument in braces to make it visually stand out from the other arguments. When you put braces around any of the special package-level file handles like STDOUT, STDERR, and DATA, you must add the * sigil or else it won't compile under use strict 'subs'.
print $FH "Mary had a little lamb\n"; #not ok
print {$FH} "Mary had a little lamb\n"; #ok
print STDERR $foo, $bar, $baz; #not ok
print {STDERR} $foo, $bar, $baz; #won't compile under 'strict'
print {*STDERR} $foo, $bar, $baz; #perfect!
it's giving "make the filehandle the main character" and honestly? the braces ate. π
π CONFIGURATION π
This Policy is not configurable except for the standard options. That's it. No secret menu, no extra little knobs to twiddle, bestie. π«Ά
π AUTHOR π
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> π
π COPYRIGHT π
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.
okay that's the tea β β this cutie came from the perl v5.42.0 docs, dated 2024-10-23, with the Perl::...thPrint(3pm) footer energy folded in at the end. mwah ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Perl-Critic 1.156.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms