1Perl::Critic::Policy::MUosdeurPleeCrsol:n::t:PrCrirobihutitibecid:t:PPPOeoSrlIliXciDymo:pc:ouMrmoted(nu3tl)aetsi:o:nProhibitPOSIXimport(3)
2
3
4

NAME

6       Perl::Critic::Policy::Modules::ProhibitPOSIXimport - don't import the
7       whole of POSIX into a module
8

DESCRIPTION

10       This policy is part of the "Perl::Critic::Pulp" add-on.  It asks you
11       not to "use POSIX" with an import of all the symbols from that module
12       if you're only using a few things.
13
14           package Foo;
15           use POSIX;    # bad
16
17       The aim is to save some memory, and maybe run a bit faster.  A full
18       "POSIX" import adds about 550 symbols to your module and that's about
19       30 to 40 kbytes in Perl 5.10 on a 32-bit system, or about 115 kbytes in
20       Perl 5.8.  If lots of modules do this then it adds up.
21
22       As noted in the "POSIX" module docs, the way it exports everything by
23       default is an historical accident, not something to encourage.
24
25   Allowed Forms
26       A full import is allowed in "package main", which is the top-level of a
27       script etc, since in a script you want convenience rather than a bit of
28       memory, at least initially.
29
30           #!/usr/bin/perl
31           use POSIX;        # ok
32
33       An import of no symbols is allowed and you then add a "POSIX::"
34       qualifier to each call or constant.  Qualifiers like this can make it
35       clear where the function is coming from.
36
37           package Foo;
38           use POSIX (); # ok
39
40           my $fd = POSIX::dup(0);
41           if ($! == POSIX::ENOENT())
42
43       An import of an explicit set of functions and constants is allowed.
44       This allows short names without the memory penalty of a full import.
45       However it can be error-prone to update the imports with what you
46       actually use (see "ProhibitCallsToUndeclaredSubs" for some checking).
47
48           package Foo;
49           use POSIX qw(dup ENOENT); # ok
50           ...
51           my $fd = dup(0);
52
53       A full import is allowed in a module if there's 15 or more calls to
54       "POSIX" module functions.  This rule might change or be configurable in
55       the future, but the intention is that a module making heavy use of
56       "POSIX" shouldn't be burdened by a "POSIX::" on every call or by
57       maintaining a list of explicit imports.
58
59           package Foo;
60           use POSIX;         # ok
61           ...
62           tzset(); dup(1)... # 15 or more calls to POSIX stuff
63
64   Disabling
65       If you don't care this sort of thing you can always disable
66       "ProhibitPOSIXimport" from your .perlcriticrc in the usual way (see
67       "CONFIGURATION" in Perl::Critic),
68
69           [-Modules::ProhibitPOSIXimport]
70

SEE ALSO

72       POSIX, Perl::Critic::Pulp, Perl::Critic,
73       Perl::Critic::Policy::Subroutines::ProhibitCallsToUndeclaredSubs
74

HOME PAGE

76       <http://user42.tuxfamily.org/perl-critic-pulp/index.html>
77
79       Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin
80       Ryde
81
82       Perl-Critic-Pulp is free software; you can redistribute it and/or
83       modify it under the terms of the GNU General Public License as
84       published by the Free Software Foundation; either version 3, or (at
85       your option) any later version.
86
87       Perl-Critic-Pulp is distributed in the hope that it will be useful, but
88       WITHOUT ANY WARRANTY; without even the implied warranty of
89       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
90       General Public License for more details.
91
92       You should have received a copy of the GNU General Public License along
93       with Perl-Critic-Pulp.  If not, see <http://www.gnu.org/licenses/>.
94
95
96
97perl v5.30.0             Perl::Cri2t0i1c9:-:0P7o-l2i6cy::Modules::ProhibitPOSIXimport(3)
Impressum