Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub follow(IO::Handle $fh --> Supply) {
- $fh.seek(0, SeekFromEnd);
- supply {
- while True {
- my $line = $fh.get;
- with $line {
- emit $line;
- } else {
- sleep 0.1;
- }
- }
- }
- }
- sub grep($pattern, Supply $lines --> Supply) {
- supply {
- whenever $lines -> $line {
- if $line.contains($pattern) {
- $line.emit;
- }
- }
- }
- }
- sub MAIN(Str $file) {
- my $fh = open($file);
- react {
- whenever $fh ==> &follow() ==> &grep("perl6") {
- .say;
- }
- }
- $fh.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement