V
V S Rawat
1. I am currently doing it like this:
--------------
do {
print "Font Name (1: Arjun, 2: Shree709, 3: Shusha, 0: Exit)? \n";
use Term::ReadKey;
ReadMode 4; # Turn off controls keys
while (not defined ($C1_map_opt = ReadKey(-1))) { # No key yet
}
if ( $Debug_flag == 1 ) { # $Debug_flag has already been defined
print "Get key $C1_map_opt\n";
}
ReadMode 0; # Reset tty mode before exiting
} until ( $C1_map_opt >= 0 && $C1_map_opt <= 3 );
--------------
Is there any method of giving a prompt (e.g. "Font Name (1: Arjun, 2:
Shree709, 3: Shusha, 0: Exit)? \n") with ReadKey? I mean, the way we
can do with ReadLine as in:
---------
my $prompt = "Input file name (0: Exit)? ";
$term->readline($prompt)
-------------------
That would avoid me writing a separate line some three lines before the
actual readkey command.
---------------------------------------------
2. The following is not reaching "entered file name: " line, nor is
exiting at 0.
----------------
use Term::ReadLine;
my $term = new Term::ReadLine 'Simple Perl calc';
my $prompt = "Input file name (0: Exit)? ";
my $OUT = $term->OUT || \*STDOUT;
while ( defined ($_ = $term->readline($prompt)) ) {
$InFile = eval($_);
warn $@ if $@;
print $OUT $InFile, "\n" unless $@;
$term->addhistory($_) if /\S/;
}
if ($InFile == "0") {
exit;
}
print "entered file name: ", $InFile, "\n";
--------------
do {
print "Font Name (1: Arjun, 2: Shree709, 3: Shusha, 0: Exit)? \n";
use Term::ReadKey;
ReadMode 4; # Turn off controls keys
while (not defined ($C1_map_opt = ReadKey(-1))) { # No key yet
}
if ( $Debug_flag == 1 ) { # $Debug_flag has already been defined
print "Get key $C1_map_opt\n";
}
ReadMode 0; # Reset tty mode before exiting
} until ( $C1_map_opt >= 0 && $C1_map_opt <= 3 );
--------------
Is there any method of giving a prompt (e.g. "Font Name (1: Arjun, 2:
Shree709, 3: Shusha, 0: Exit)? \n") with ReadKey? I mean, the way we
can do with ReadLine as in:
---------
my $prompt = "Input file name (0: Exit)? ";
$term->readline($prompt)
-------------------
That would avoid me writing a separate line some three lines before the
actual readkey command.
---------------------------------------------
2. The following is not reaching "entered file name: " line, nor is
exiting at 0.
----------------
use Term::ReadLine;
my $term = new Term::ReadLine 'Simple Perl calc';
my $prompt = "Input file name (0: Exit)? ";
my $OUT = $term->OUT || \*STDOUT;
while ( defined ($_ = $term->readline($prompt)) ) {
$InFile = eval($_);
warn $@ if $@;
print $OUT $InFile, "\n" unless $@;
$term->addhistory($_) if /\S/;
}
if ($InFile == "0") {
exit;
}
print "entered file name: ", $InFile, "\n";