File: to.pl

package info (click to toggle)
libio-prompt-perl 0.997004-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 228 kB
  • sloc: perl: 846; makefile: 2
file content (27 lines) | stat: -rwxr-xr-x 544 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /usr/bin/perl -w

# A filehandle in the argument list causes the prompt to be sent to
# that filehandle, rather than to the terminal...
#

use IO::Prompt;

open my $fh, '>/dev/null' or die $!;

print "No prompt should appear here... (type anything)\n";
if (prompt $fh, "> ", -line) {
    print;
}

if (prompt \*STDERR, "type some more> ", -line) {
    print;
}

use IO::File;
$fh = new IO::File, "<$0" or die $!;

print "This should fail at line ", __LINE__ + 1,
  " (read-only filehandle)...\n";
if (prompt $fh, "> ", -line) {
    print;
}