In my program, I'd like to read a line from $*IN
in a loop, and for this I can use either get
or prompt
; however, I noticed that if I end my input immediately with EOF (e.g., with Ctrl-D in Linux / MacOS) then any subsequent uses of get
or prompt
for reading another line from $*IN
will cause it to return Nil
, meaning it still gets EOF from $*IN
.
Example:
dd get;
dd get;
with an immediate EOF (ctrl-d), the program ends and outputs two Nil
's.
This problem doesn't happen if something is entered other than just a EOF.
Curiously, this problem also doesn't happen with slurp
. I.e.,
dd slurp;
dd slurp;
After the first ctrl-d, ""
is printed by the first dd
and then it waits for input due to the second slurp
.
I think this is also them same problem with - https://github.com/rakudo/rakudo/issues/4196