--- a/PhishTag.pm
+++ b/PhishTag.pm
@@ -1,7 +1,27 @@
-package PhishTag;
+# <@LICENSE>
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to you under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at:
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# # Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# </@LICENSE>
+#
+###########################################################################
+
+package Mail::SpamAssassin::Plugin::PhishTag;
 
 use strict;
 use warnings;
+use Errno qw(EBADF);
 use Mail::SpamAssassin;
 use Mail::SpamAssassin::Logger;
 
@@ -10,17 +30,17 @@
 our @ISA = qw(Mail::SpamAssassin::Plugin);
 
 sub new{
-    my ($class, $mailsa)=@_;
-    $class=ref($class) ||$class;
-    my $self = $class->SUPER::new($mailsa);
-    bless($self,$class);
-    $self->set_config($mailsa->{conf});
-    return $self;
+  my ($class, $mailsa)=@_;
+  $class=ref($class) ||$class;
+  my $self = $class->SUPER::new($mailsa);
+  bless($self,$class);
+  $self->set_config($mailsa->{conf});
+  return $self;
 }
 
 sub set_config{
   my($self, $conf) = @_;
-  my @cmds = ();
+  my @cmds;
 
   push (@cmds, {
     setting => 'trigger_target',
@@ -85,8 +105,9 @@
   my $targets= $pms->{PHISHTAG}->{targets};
 
   my $target;
+  local *F;
   open(F, '<', $pms->{conf}->{trigger_config});
-  while(<F>){
+  for ($!=0; <F>; $!=0) {
       #each entry is separated by blank lines
       undef($target) if(!/\S/);
 
@@ -106,7 +127,10 @@
 	  push @$target, $_;
       }
   }
-  close(F);
+  defined $_ || $!==0  or
+    $!==EBADF ? dbg("PHISHTAG: error reading config file: $!")
+              : die "error reading config file: $!";
+  close(F)  or die "error closing config file: $!";
 }
 
 sub hit_rule {
@@ -128,7 +152,7 @@
   #find out which targets have fulfilled their requirements
   my $triggers= $pms->{PHISHTAG}->{triggers};
   my $targets= $pms->{PHISHTAG}->{targets};
-  my @filled=();
+  my @filled;
   foreach my $target(@$targets){
       my $uri= $$target[0];
       my $fulfilled=1;
@@ -190,23 +214,18 @@
 
 =head1 SYNOPSIS
 
-=over 4
-
-    loadplugin     Mail::SpamAssassin::Plugin::PhishTag
+ loadplugin     Mail::SpamAssassin::Plugin::PhishTag
 
-    trigger_ratio    0.1
-    trigger_target   RULE_NAME  http://www.antiphishing.org/consumer_recs.html
+ trigger_ratio    0.1
+ trigger_target   RULE_NAME  http://www.antiphishing.org/consumer_recs.html
 
-=back
-    
 =head1 DESCRIPTION
 
-PhishTag enables administrators to rewrite links in emails that trigger 
-certain tests; preferrable blacklist tests. The plugin will inhibit the 
-blocking of a portion of the emails that trigger the test by SpamAssassin, 
-and let them pass to the users' inbox after the rewrite. It is useful in 
-providing training to email users about company policies and general email 
-usage.
+PhishTag enables administrators to rewrite links in emails that trigger certain
+tests, preferably anti-phishing blacklist tests. The plugin will inhibit the
+blocking of a portion of the emails that trigger the test by SpamAssassin, and
+let them pass to the users' inbox after the rewrite. It is useful in providing
+training to email users about company policies and general email usage.
 
 =head1 OPTIONS
 
