[perltidy] Mail::IMAPClient
authorMatthias Förste foerste@schlittermann.de
Wed, 09 Nov 2011 11:09:41 +0100
branchMail::IMAPClient
changeset 7 493a7595db03
parent 6 21856a9e3ad3
child 8 262cfae21b61
[perltidy]
isearch
--- a/isearch	Wed Nov 09 10:42:13 2011 +0100
+++ b/isearch	Wed Nov 09 11:09:41 2011 +0100
@@ -36,12 +36,12 @@
 GetOptions(
     "charset=s"    => \$opts->{charset},
     "c|criteria=s" => \$opts->{criteria},
-    "h|help"       => sub { pod2usage( -verbose => 0, -exitval => 0 ) },
+    "h|help"       => sub { pod2usage(-verbose => 0, -exitval => 0) },
     "m|man"        => sub {
         pod2usage(
             -verbose   => 2,
             -exitval   => 0,
-            -noperldoc => ( `perldoc -V 2>/dev/null`, $? != 0 )[-1]
+            -noperldoc => (`perldoc -V 2>/dev/null`, $? != 0)[-1]
         );
     },
     "password=s" => \$imapopts{Password},
@@ -51,9 +51,9 @@
 ) or pod2usage();
 defined $opts->{criteria} and defined $imapopts{User} or pod2usage();
 
-if ( defined $imapopts{Password} ) {
+if (defined $imapopts{Password}) {
 
-    if ( -r $imapopts{Password} ) {
+    if (-r $imapopts{Password}) {
 
         open P, '<', $imapopts{Password}
           or die "Can't open '$imapopts{Password}' for reading: $!\n";
@@ -76,7 +76,7 @@
 my $imap = Mail::IMAPClient->new(%imapopts)
   or die "Could not connect to IMAP server\n";
 
-my $f = ( @ARGV or $imap->folders );
+my $f = (@ARGV or $imap->folders);
 die "Can't get folderlist: " . $imap->LastError . "\n" unless $f;
 
 my $mids;
@@ -89,23 +89,29 @@
     unless ($imap->examine($_)) {
 
         my $e = $imap->LastError;
+
         # skip folder with invalid name
-        if ($e =~ /BAD Error in IMAP command EXAMINE: 8bit data in atom$/
+        if (   $e =~ /BAD Error in IMAP command EXAMINE: 8bit data in atom$/
             or $e =~ /NO Invalid mailbox name: /) {
+
             warn "Can't examine '$_': $e\n";
             print "Skipping $_ ...\n";
             next;
+
         } else {
+
             die "Can't examine '$_': $e\n";
+
         }
 
     }
 
     print "Searching $_ ...\n";
-    if ( my $m = $imap->search( $opts->{criteria} )) {
+    if (my $m = $imap->search($opts->{criteria})) {
         $mids->{$_} = $m;
     } else {
         my $e = $imap->LastError;
+
         # dovecots fts plugin may just crash and cause the connection to drop
         # (this happened when searching a mailbox containing just gzipped mail
         # files and results in log messages like these:
@@ -115,7 +121,7 @@
         if ($e eq 'socket closed while reading data from server') {
             warn "Can't search '$_': $e\n";
             $imap->connect
-                or die "Could not connect to IMAP server: $@\n";
+              or die "Could not connect to IMAP server: $@\n";
         } else {
 
             die "Can't search '$_': $e\n";
@@ -126,22 +132,22 @@
 }
 
 my @headers = qw(subject from to cc bcc date);
-for my $f ( sort keys %{$mids} ) {
+for my $f (sort keys %{$mids}) {
 
     my $m = $mids->{$f};
 
-    if ( @{$m} ) {
+    if (@{$m}) {
 
         $imap->examine($f)
           or die "Can't examine: " . $imap->LastError . "\n";
-        my $h = $imap->parse_headers( $mids->{$f}, @headers )
+        my $h = $imap->parse_headers($mids->{$f}, @headers)
           or die "Can't get summaries: " . $imap->LastError . "\n";
 
-        for my $id ( keys %{$h} ) {
+        for my $id (keys %{$h}) {
 
             print "\n[$f] [$id]\n";
             for my $hn (@headers) {
-                print ucfirst $hn . ": $_\n" for @{$h->{$id}->{$hn}};
+                print ucfirst $hn . ": $_\n" for @{ $h->{$id}->{$hn} };
             }
 
         }