Perl::...kedOpen(3pm)
β¨ NAME β¨
okay so bestie, this is the Perl::...kedOpen(3pm) page from User Contributed Perl Documentation, and the policy is Perl::Critic::Policy::InputOutput::RequireCheckedOpen β write my $error = open $fh, $mode, $filename; instead of open $fh, $mode, $filename;. Thatβs the assignment, no cap π
π AFFILIATION π
This Policy is part of the core Perl::Critic distribution β core distribution energy, periodt π¦
π DESCRIPTION π
The perl builtin I/O function open returns a false value on failure. That value should always be checked to ensure that the open was successful. Like, always always π
my $error = open( $filehandle, $mode, $filename ); # ok
open( $filehandle, $mode, $filename ) or die "unable to open: $!"; # ok
open( $filehandle, $mode, $filename ); # not ok
use autodie;
open $filehandle, $mode, $filename; # ok
You can use autodie, Fatal, or Fatal::Exception to get around this. Currently, autodie is not properly treated as a pragma; its lexical effects aren't taken into account. Thatβs a real caveat, so donβt let the autodie vibe fool you π
π οΈ CONFIGURATION π οΈ
If you create a module that exports autodie you can tell this policy about it with the autodie_modules setting:
[InputOutput::RequireCheckedSyscalls]
autodie_modules = My::Thing
π AUTHOR π
Andrew Moore <amoore@mooresystems.com> β icon behavior π«Ά
πΈ ACKNOWLEDGMENTS πΈ
This policy module is based heavily on policies written by Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>. Shoutout to the source material, fr fr π
π COPYRIGHT π
Copyright (c) 2007-2011 Andrew Moore. 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.
byeee bestie β this page is from User Contributed Perl Documentation with perl v5.42.0, dated 2024-10-23 π
β¨
π¦ 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