Thread Ablauf bei zu langen Tasks (7 answers)
Opened by peterb at 2022-06-14 10:06

hlubenow
 2022-06-16 15:14
#194380 #194380
User since
2009-02-22
875 Artikel
BenutzerIn
[default_avatar]
Like this:
Code (perl): (dl )
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
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl

use warnings;
use strict;

use Term::ReadKey;

sub readInput {
    ReadMode(4);
    my $line = "";
    my $key  = " ";
    my $other_condition = 100;

    # 10 is the ord() of the newline character:
    while (ord($key) != 10) {

        # You can check for other conditions during input here:
        if ($other_condition != 100) {
            print "\n";
            last;
        }

        while (not defined ($key = ReadKey(-1))) {
        }
        print $key;
        if (ord($key) != 10) {
            $line .= $key;
        }
        # $other_condition = 20;
    }

    ReadMode(0);
    return $line;
}

my $result = readInput();
print "Result is: $result\n";

View full thread Ablauf bei zu langen Tasks