}
}
+sub getfiles {
+ my $dir = shift;
+ my @result;
+
+ if (not opendir(DIR, $dir)) {
+ err(&EX_TEMPFAIL, "Failed opendir($dir)");
+ }
+
+ # Initialize $! to 0 (success) because stupid stupid Perl provides
+ # no way to distinguish an error from an empty directory; that
+ # means setting $! to 0 and testing it afterwards is the only way
+ # to detect an error. Real Programmers don't handle errors,
+ # right? >sigh<
+ $! = 0;
+ @result = grep {
+ ($_ ne '.' and $_ ne '..')
+ and $_ = "$MAILDIR/new/$_"
+ } readdir(DIR);
+
+ if ($! != 0) {
+ err(&EX_TEMPFAIL, "Failed readdir($dir)");
+ }
+
+ closedir(DIR);
+
+ return @result;
+}
+
# We want to print the name of each list that has new mail only once,
# so use this hash to store the lists that have already been printed.
# Start the list out with SPAM already in it, since we don't care when
return %headers;
}
-sub getfiles {
- my $dir = shift;
- my @result;
-
- if (not opendir(DIR, $dir)) {
- err(&EX_TEMPFAIL, "Failed opendir($dir)");
- }
-
- # Initialize $! to 0 (success) because stupid stupid Perl provides
- # no way to distinguish an error from an empty directory; that
- # means setting $! to 0 and testing it afterwards is the only way
- # to detect an error. Real Programmers don't handle errors,
- # right? >sigh<
- $! = 0;
- @result = grep {
- ($_ ne '.' and $_ ne '..')
- and $_ = "$MAILDIR/new/$_"
- } readdir(DIR);
-
- if ($! != 0) {
- err(&EX_TEMPFAIL, "Failed readdir($dir)");
- }
-
- closedir(DIR);
-
- return @result;
-}
-
\f
###############################################################################
# Spam handling