1IO::Interactive(3)    User Contributed Perl Documentation   IO::Interactive(3)
2
3
4

NAME

6       IO::Interactive - Utilities for interactive I/O
7

VERSION

9       This document describes IO::Interactive version 1.02
10

SYNOPSIS

12           use IO::Interactive qw(is_interactive interactive busy);
13
14           if ( is_interactive() ) {
15               print "Running interactively\n";
16           }
17
18           # or...
19
20           print {interactive} "Running interactively\n";
21
22
23           $fh = busy {
24               do_noninteractive_stuff();
25           }
26

DESCRIPTION

28       This module provides three utility subroutines that make it easier to
29       develop interactive applications...
30
31       "is_interactive()"
32           This subroutine returns true if *ARGV and the currently selected
33           filehandle (usually *STDOUT) are connected to the terminal. The
34           test is considerably more sophisticated than:
35
36               -t *ARGV && -t *STDOUT
37
38           as it takes into account the magic behaviour of *ARGV.
39
40           You can also pass "is_interactive" a writable filehandle, in which
41           case it requires that filehandle be connected to a terminal
42           (instead of the currently selected).  The usual suspect here is
43           *STDERR:
44
45               if ( is_interactive(*STDERR) ) {
46                   carp $warning;
47               }
48
49       "interactive()"
50           This subroutine returns *STDOUT if "is_interactive" is true. If
51           "is_interactive()" is false, "interactive" returns a filehandle
52           that does not print.
53
54           This makes it easy to create applications that print out only when
55           the application is interactive:
56
57               print {interactive} "Please enter a value: ";
58               my $value = <>;
59
60           You can also pass "interactive" a writable filehandle, in which
61           case it writes to that filehandle if it is connected to a terminal
62           (instead of writing to *STDOUT). Once again, the usual suspect is
63           *STDERR:
64
65               print {interactive(*STDERR)} $warning;
66
67       "busy {...}"
68           This subroutine takes a block as its single argument and executes
69           that block.  Whilst the block is executed, *ARGV is temporarily
70           replaced by a closed filehandle. That is, no input from *ARGV is
71           possible in a "busy" block.  Furthermore, any attempts to send
72           input into the "busy" block through *ARGV is intercepted and a
73           warning message is printed to *STDERR.  The "busy" call returns a
74           filehandle that contains the intercepted input.
75
76           A "busy" block is therefore useful to prevent attempts at input
77           when the program is busy at some non-interactive task.
78

DIAGNOSTICS

80       Unknown subroutine (%s) requested
81           This module only exports the three subroutines described above.
82           You asked for something else. Maybe you misspelled the subroutine
83           you wanted.
84

CONFIGURATION AND ENVIRONMENT

86       IO::Interactive requires no configuration files or environment
87       variables.
88

DEPENDENCIES

90       This module requires the "openhandle()" subroutine from the
91       Scalar::Util module.
92

INCOMPATIBILITIES

94       None reported.
95

BUGS AND LIMITATIONS

97       No bugs have been reported.
98
99       Please report any bugs or feature requests to Github
100       <https://github.com/briandfoy/io-interactive/issues>.
101

SOURCE AVAILABILITY

103       This code is in GitHub:
104
105               https://github.com/briandfoy/io-interactive
106

AUTHOR

108       Damian Conway  "<DCONWAY@cpan.org>"
109
110       Currently maintained by brian d foy "<bdfoy@cpan.org>".
111
112       1.01 patch DMUEY "dmuey@cpan.org"
113
115       Copyright (c) 2005, Damian Conway "<DCONWAY@cpan.org>". All rights
116       reserved.
117
118       This module is free software; you can redistribute it and/or modify it
119       under the same terms as Perl itself.
120

DISCLAIMER OF WARRANTY

122       BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
123       FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT
124       WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
125       PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND,
126       EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
127       WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
128       ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
129       YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
130       NECESSARY SERVICING, REPAIR, OR CORRECTION.
131
132       IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
133       WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
134       REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE
135       TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR
136       CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
137       SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
138       RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
139       FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
140       SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
141       DAMAGES.
142
143
144
145perl v5.30.1                      2020-01-30                IO::Interactive(3)
Impressum