Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. sub follow(IO::Handle $fh --> Supply) {
  2. $fh.seek(0, SeekFromEnd);
  3. supply {
  4. while True {
  5. my $line = $fh.get;
  6. with $line {
  7. emit $line;
  8. } else {
  9. sleep 0.1;
  10. }
  11. }
  12. }
  13. }
  14.  
  15. sub grep($pattern, Supply $lines --> Supply) {
  16. supply {
  17. whenever $lines -> $line {
  18. if $line.contains($pattern) {
  19. $line.emit;
  20. }
  21. }
  22. }
  23. }
  24.  
  25. sub MAIN(Str $file) {
  26. my $fh = open($file);
  27. react {
  28. whenever $fh ==> &follow() ==> &grep("perl6") {
  29. .say;
  30. }
  31. }
  32. $fh.close();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement