blib/lib/IO/ExplicitHandle.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 20 / 20 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Build ↑ Summary
1 =head1 NAME
2  
3 IO::ExplicitHandle - detect implicit I/O handles when compiling
4  
5 =head1 SYNOPSIS
6  
7 use IO::ExplicitHandle;
8  
9 no IO::ExplicitHandle;
10  
11 =head1 DESCRIPTION
12  
13 This module provides a lexically-scoped pragma that prohibits I/O
14 operations that use an implicit default I/O handle. For example, C<print
15 123> implicitly uses the "currently selected" I/O handle (controlled
16 by L<select|perlfunc/select>). Within the context of the pragma, I/O
17 operations must be explicitly told which handle they are to operate on.
18 For example, C<print STDOUT 123> explicitly uses the program's standard
19 output stream.
20  
21 The affected operations that use the "currently selected" I/O handle are
22 L<print|perlfunc/print>, L<printf|perlfunc/printf>, L<say|perlfunc/say>,
23 L<close|perlfunc/close>, L<write|perlfunc/write>, and the magic variables
24 L<$E<verbar>|perlvar/$E<verbar>>, L<$^|perlvar/$^>, L<$~|perlvar/$~>,
25 L<$=|perlvar/$=>, L<$-|perlvar/$->, and L<$%|perlvar/$%>. The affected
26 operations that use the "last read" I/O handle are L<eof|perlfunc/eof>,
27 L<tell|perlfunc/tell>, and the magic variable L<$.|perlvar/$.>. One form
28 of the L<..|perlop/..> operator can implicitly read L<$.|perlvar/$.>,
29 but it cannot be reliably distinguished at compile time from the more
30 common list-generating form, so it is not affected by this module.
31  
32 =cut
33  
34 package IO::ExplicitHandle;
35  
36 3 ▶{ use 5.006; }
Subroutine BEGIN: called CC=1 SCAR=0.0
37 3 ▶use Lexical::SealRequireHints 0.007;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 3 our $VERSION = "0.000";
42  
43 3 require XSLoader;
44 3 XSLoader::load(__PACKAGE__, $VERSION);
45  
46 =head1 PACKAGE METHODS
47  
48 =over
49  
50 =item IO::ExplicitHandle->import
51  
52 Turns on the I/O handle stricture in the lexical environment that is
53 currently compiling.
54  
55 =item IO::ExplicitHandle->unimport
56  
57 Turns off the I/O handle stricture in the lexical environment that is
58 currently compiling.
59  
60 =back
61  
62 =head1 BUGS
63  
64 The L<..|perlop/..> operator decides only at runtime whether it will
65 read from L<$.|perlvar/$.>, and hence implicitly use the "last read"
66 I/O handle. It does this if called in scalar context. If the same
67 expression is called in list context, it generates a list of numbers,
68 unrelated to L<$.|perlvar/$.>. This semantic overloading prevents the
69 problematic use of L<..|perlop/..> being detected at compile time.
70  
71 =head1 SEE ALSO
72  
73 L<strict>
74  
75 =head1 AUTHOR
76  
77 Andrew Main (Zefram) <zefram@fysh.org>
78  
79 =head1 COPYRIGHT
80  
81 Copyright (C) 2012 Andrew Main (Zefram) <zefram@fysh.org>
82  
83 =head1 LICENSE
84  
85 This module is free software; you can redistribute it and/or modify it
86 under the same terms as Perl itself.
87  
88 =cut
89  
90 3 1;
« Build ↑ Summary