尝试使用https://grepular.com/projects/IMAPExpire
$ ./imapexpire.pl --test --user user --passfile ~/imapexpire.pass --folders exceptions --age 100 --host myserver
TEST : You're running in test mode, so the deletions wont actually take place
ACTION: Delete mail which arrived before 27-Jan-2015 from: exceptions
Use of uninitialized value $line in substitution (s///) at /usr/local/share/perl5/IMAP/Client.pm line 560, <GEN0> line 14.
Client.pm:555:
sub parse_search (@) {
my (@resp) = @_;
my @results = ();
# find SEARCH line and process results
foreach my $line (@resp) {
next unless ($line =~ s/^\*\s+SEARCH\s+([\d+\s]+)\s*\r\n$/$1/);
@results = split(/ /,$line);
last; # theres only 1 line
}
return(wantarray ? @results : @results ? sequencify(@results) : undef );
}
如果$line
未初始化,为什么foreach
会重复?
我在RHEL 6.5上。跑yum install perl-IO-Socket-SSL
和cpan IMAP::Client
。
答案 0 :(得分:2)
因为数组可以包含undef
。
my @list_of_things = ( "fish", undef, "carrot" );
foreach my $line ( @list_of_things ) {
print $line;
}
你可能通过undef
注入了@resp
,但是没有看到那里发生了什么,我不知道它是从哪里来的。
解决方法可能是:
next unless defined $line;