]> Sergey Matveev's repositories - public-inbox.git/commitdiff
learn: pass global variables into subs
authorEric Wong <e@80x24.org>
Fri, 15 Nov 2019 09:50:38 +0000 (09:50 +0000)
committerEric Wong <e@80x24.org>
Sat, 16 Nov 2019 11:05:23 +0000 (11:05 +0000)
Avoid 'Variable "%s" will not stay shared' warnings
when the contents of this script eval'ed into a sub.

script/public-inbox-learn

index 3073294a18bb526138d24e6898325157726c9586..93aece2e66b6c0d0fecf1d718070e5e213099f7a 100644 (file)
@@ -39,8 +39,8 @@ my $mime = PublicInbox::MIME->new(eval {
        $data
 });
 
-sub remove_or_add ($$$) {
-       my ($ibx, $train, $addr) = @_;
+sub remove_or_add ($$$$) {
+       my ($ibx, $train, $mime, $addr) = @_;
 
        # We do not touch GIT_COMMITTER_* env here so we can track
        # who trained the message.
@@ -93,12 +93,12 @@ if ($train eq 'spam') {
        while (my ($addr, $ibx) = each %dests) {
                next unless ref($ibx); # $ibx may be 0
                next if $seen{"$ibx"}++;
-               remove_or_add($ibx, $train, $addr);
+               remove_or_add($ibx, $train, $mime, $addr);
        }
        my $dests = PublicInbox::MDA->inboxes_for_list_id($pi_config, $mime);
        for my $ibx (@$dests) {
                next if !$seen{"$ibx"}++;
-               remove_or_add($ibx, $train, $ibx->{-primary_address});
+               remove_or_add($ibx, $train, $mime, $ibx->{-primary_address});
        }
 }