#!/usr/bin/env perl6 use v6.d.PREVIEW; use lib 'lib'; use MaildirIndexer::ScanDir; use MaildirIndexer::Parser; sub MAIN($maildir) { my $file-supply = scan-dir($maildir); my $file-channel = $file-supply.Channel; for ^10 { start react { whenever $file-channel -> $file { if $file.e && $file.f { my $email = parse-email($file,:headers-only); say "{$file} - {$email}"; } } } } react whenever signal(SIGINT) { exit } }