Thread Ablauf bei zu langen Tasks
(7 answers)
Opened by peterb at 2022-06-14 10:06
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"; |