Advertisement
hakonhagland

raku reopen stdin

Apr 12th, 2021
3,393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.37 KB | None | 0 0
  1. use v6;
  2. print "Input line: ";
  3. my $line = get;
  4. if ($line === Any) {
  5.     say "got EOF..";
  6.     say "Reopening STDIN..";
  7.     $*IN.close;
  8.     my $fh = open "/dev/tty", :r, chomp => $*IN.chomp, nl-in => $*IN.nl-in,
  9.         encoding => $*IN.encoding;
  10.     $*IN = $fh;
  11.     my $line = get;
  12.     say "Got line: {$line}";
  13. }
  14. else {
  15.     say "Not EOF, got line: {$line}";
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement