diff --git a/lib/IdPAccountManager/SAMLMetadata.pm b/lib/IdPAccountManager/SAMLMetadata.pm
index 909e222f2422b48cc259ac47afd4b516ae39da55..ffb7a84a95fe95d0166b763108d0ed34869067f0 100644
--- a/lib/IdPAccountManager/SAMLMetadata.pm
+++ b/lib/IdPAccountManager/SAMLMetadata.pm
@@ -7,6 +7,7 @@ package IdPAccountManager::SAMLMetadata;
 use strict;
 use warnings;
 
+use English qw(-no_match_vars);
 use IdPAccountManager::Tools;
 use IdPAccountManager::Logger;
 
@@ -45,7 +46,7 @@ sub load {
         $self->{logger}->log(
             level => LOG_ERROR,
             message =>
-              "Failed to read $in{'federation_metadata_file_path'} : $!"
+              "Failed to read $in{'federation_metadata_file_path'} : $ERRNO"
         );
         return undef;
     }
@@ -55,7 +56,7 @@ sub load {
     {
         $self->{logger}->log(
             level   => LOG_ERROR,
-            message => "Failed to parse file $in{'metadata_file'} : $!"
+            message => "Failed to parse file $in{'metadata_file'} : $ERRNO"
         );
         return undef;
     }
@@ -122,7 +123,7 @@ sub _get_xml_object {
     unless (-f $metadata_file) {
         $self->{logger}->log(
             level   => LOG_ERROR,
-            message => "File $metadata_file not found: $!"
+            message => "File $metadata_file not found: $ERRNO"
         );
         return undef;
     }
@@ -130,7 +131,7 @@ sub _get_xml_object {
     unless (open FH, $metadata_file) {
         $self->{logger}->log(
             level   => LOG_ERROR,
-            message => "Failed to open file $metadata_file: $!"
+            message => "Failed to open file $metadata_file: $ERRNO"
         );
         return undef;
     }
@@ -149,10 +150,10 @@ sub _get_xml_object {
 
     ## Eval() prevents the parsing from killing the main process
     eval { $doc = $parser->parse_fh(\*FH) };
-    if ($@) {
+    if ($EVAL_ERROR) {
         $self->{logger}->log(
             level   => LOG_ERROR,
-            message => "Failed to parse file $metadata_file : $@"
+            message => "Failed to parse file $metadata_file : $EVAL_ERROR"
         );
         return undef;
     }
@@ -160,7 +161,7 @@ sub _get_xml_object {
     unless ($doc) {
         $self->{logger}->log(
             level   => LOG_ERROR,
-            message => "Failed to parse file $metadata_file : $!"
+            message => "Failed to parse file $metadata_file : $ERRNO"
         );
         return undef;
     }
diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm
index e6f41f0a9d1964394a49150a254841c5a3cb3898..0666cb9d316c943bb4c858dad53082e285b0fd6f 100755
--- a/lib/IdPAccountManager/WebRequest.pm
+++ b/lib/IdPAccountManager/WebRequest.pm
@@ -3,6 +3,7 @@ package IdPAccountManager::WebRequest;
 use strict;
 use warnings;
 
+use English qw(-no_match_vars);
 use IdPAccountManager::Logger;
 use Conf;
 
@@ -221,7 +222,7 @@ sub req_account_wizard {
         push @{ $self->{'param_out'}{'errors'} }, "internal";
         $self->{logger}->log(
             level   => LOG_ERROR,
-            message => "Failed to load federation metadata : $!"
+            message => "Failed to load federation metadata : $ERRNO"
         );
         return undef;
     }
@@ -230,7 +231,7 @@ sub req_account_wizard {
         push @{ $self->{'param_out'}{'errors'} }, "internal";
         $self->{logger}->log(
             level   => LOG_ERROR,
-            message => "Failed to parse federation metadata : $!"
+            message => "Failed to parse federation metadata : $ERRNO"
         );
         return undef;
     }
@@ -268,7 +269,7 @@ sub req_select_sp {
         push @{ $self->{'param_out'}{'errors'} }, "internal";
         $self->{logger}->log(
             level   => LOG_ERROR,
-            message => "Failed to load federation metadata : $!"
+            message => "Failed to load federation metadata : $ERRNO"
         );
         return undef;
     }
@@ -282,7 +283,7 @@ sub req_select_sp {
         push @{ $self->{'param_out'}{'errors'} }, "internal";
         $self->{logger}->log(
             level   => LOG_ERROR,
-            message => "Failed to parse federation metadata : $!"
+            message => "Failed to parse federation metadata : $ERRNO"
         );
         return undef;
     }