inz

tbunread.perl (raw)

  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4.  
  5. sub urc {
  6. my $fn = shift;
  7. my $rv = 0;
  8. local $/ = "}\@\n";
  9. open my $fd, "<", $fn;
  10. while (my $r = <$fd>) {
  11. $rv = $1 if $r =~ /\[-?1:\^9F[^\]]*?\(\^A2=([0-9]+)\)/m;
  12. }
  13. close $fd;
  14.  
  15. return $rv;
  16. }
  17.  
  18. chdir(<$ENV{'HOME'}/.thunderbird/*.default>);
  19. open my $tail, "-|", "tail", "-n", 0, "-f", <*/*/*.msf>;
  20. my %urcs = map { $_ => urc($_) } <*/*/*.msf>;
  21. my $fn;
  22.  
  23. for (keys %urcs) {
  24. print "$_: ", $urcs{$_}, "\n" if $urcs{$_};
  25. }
  26.  
  27. $/ = "}\@\n";
  28.  
  29. while (<$tail>) {
  30. $fn = $1 if (/.*(?:^|\n)==> (.*) <==\n/s);
  31. while (/\[-?1:\^9F[^\]]*?\(\^A2=([0-9]+)\)/g) {
  32. next if $urcs{$fn} eq $1;
  33. print "$fn: $1\n";
  34. $urcs{$fn} = $1;
  35. }
  36. }
  37.