hakonhagland

raku reopen stdin

Apr 12th, 2021
541
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×