HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/share/doc/libio-prompt-perl/examples/to.pl
#! /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;
}