diff --git a/contrib/bin/fusiondirectory-insert-schema b/contrib/bin/fusiondirectory-insert-schema
index 6e5bff18a97067f9e6a030444e252e102ae1c2e6..909b21f03e3f03e988e43c59798a7c206f0f0411 100644
--- a/contrib/bin/fusiondirectory-insert-schema
+++ b/contrib/bin/fusiondirectory-insert-schema
@@ -153,18 +153,19 @@ $continue++; # activating continue feature only for insertions
 
 foreach my $schema (@schemas) {
   my $schema_name = "";
+  my $ldif_file;
 
   if ($modify < 2) {
     # Searching schema name in ldif file first line.
-    open FILE, '< '.$path.$schema.".ldif" or die "Count not open ldif file : $!\n";
+    open $ldif_file, '< '.$path.$schema.".ldif" or die "Count not open ldif file : $!\n";
     my $dn = "";
     while ($dn eq "") {
-      chomp($dn = <FILE>);
+      chomp($dn = <$ldif_file>);
     }
     if ($dn =~ /^dn: cn=([^,]+),/) {
       $schema_name = $1;
     }
-    close(FILE);
+    close($ldif_file);
   }
 
   # Fallback on file name
@@ -181,6 +182,8 @@ remove_ldifs();
 sub insert_schema
 {
   my($schema, $schema_name) = @_;
+  my $schema_file;
+  my $update_file;
 
   $full_cmd = $search_cmd.$schema_name." cn";
   print ("\n");
@@ -206,18 +209,18 @@ sub insert_schema
       my $dn_part = $1;
       # if the schema already exists in the LDAP server, modify it
       if ($modify == 1) {
-        open(SCHEMA, "<".$path.$schema.".ldif") or die_with_error('Could not open '."<".$path.$schema.".ldif: $!");
-        open(UPDATE, ">".$path.$schema."_update.ldif") or die_with_error('Could not open '.">".$path.$schema."_update.ldif: $!");
+        open($schema_file, "<".$path.$schema.".ldif") or die_with_error('Could not open '."<".$path.$schema.".ldif: $!");
+        open($update_file, ">".$path.$schema."_update.ldif") or die_with_error('Could not open '.">".$path.$schema."_update.ldif: $!");
         push @gen_files, $path.$schema."_update";
         my $attrs   = 0;
         my $classes = 0;
-        while (<SCHEMA>) {
+        while (<$schema_file>) {
           next if m/^#/; # remove comments
           chomp;
           next if m/^$/; # remove empty lines
           if (m/^dn: cn=([^,]+),cn=schema,cn=config$/) {
-            print UPDATE "dn: $dn_part,cn=schema,cn=config\n";
-            print UPDATE "changetype: modify\n";
+            print $update_file "dn: $dn_part,cn=schema,cn=config\n";
+            print $update_file "changetype: modify\n";
             next;
           }
           if (!m/^olcAttributeTypes:/ && !m/^olcObjectClasses:/ && !m/^ /) {
@@ -231,29 +234,29 @@ sub insert_schema
 
           if (!$attrs && m/^olcAttributeTypes:/) {
             $attrs = 1;
-            print UPDATE "replace: olcAttributeTypes\n";
+            print $update_file "replace: olcAttributeTypes\n";
           }
           if (!$classes && m/^olcObjectClasses:/) {
             $classes = 1;
-            print UPDATE "-\n";
-            print UPDATE "replace: olcObjectClasses\n";
+            print $update_file "-\n";
+            print $update_file "replace: olcObjectClasses\n";
           }
 
-          print UPDATE;
-          print UPDATE "\n";
+          print $update_file;
+          print $update_file "\n";
         }
-        close SCHEMA;
-        close UPDATE;
+        close $schema_file;
+        close $update_file;
       } else { # Emptying schema
-        open(UPDATE, ">".$path.$schema."_update.ldif") or die_with_error('Could not open '.">".$path.$schema."_update.ldif: $!");
+        open($update_file, ">".$path.$schema."_update.ldif") or die_with_error('Could not open '.">".$path.$schema."_update.ldif: $!");
         push @gen_files, $path.$schema."_update";
-        print UPDATE "dn: $dn_part,cn=schema,cn=config\n";
-        print UPDATE "changetype: modify\n";
-        print UPDATE "delete: olcAttributeTypes\n";
-        print UPDATE "-\n";
-        print UPDATE "delete: olcObjectClasses\n";
-        print UPDATE "-\n";
-        close UPDATE;
+        print $update_file "dn: $dn_part,cn=schema,cn=config\n";
+        print $update_file "changetype: modify\n";
+        print $update_file "delete: olcAttributeTypes\n";
+        print $update_file "-\n";
+        print $update_file "delete: olcObjectClasses\n";
+        print $update_file "-\n";
+        close $update_file;
       }
       $full_cmd = $mod_cmd.$path.$schema."_update.ldif";
       print "executing '$full_cmd'\n";
diff --git a/contrib/bin/fusiondirectory-setup b/contrib/bin/fusiondirectory-setup
index 3259b60020aad03305591ab1a7b58ae5c5ca4d5d..2b31fd9d56c7a1afb1573c197992586957d38684 100644
--- a/contrib/bin/fusiondirectory-setup
+++ b/contrib/bin/fusiondirectory-setup
@@ -729,6 +729,8 @@ sub get_ldap_connexion {
   my $uri = "";
   my $base = "";
   my $tls = 0;
+  my $secret_file;
+  my $ldap_conf;
 
   # read ldap's server's info from /etc/fusiondirectory/fusiondirectory.conf
   if (-e $fd_config) {
@@ -792,21 +794,21 @@ sub get_ldap_connexion {
 
   # bind to the LDAP server
   if (-e $fd_secrets) {
-    open(SECRETS, $fd_secrets) || die ("Could not open $fd_secrets");
+    open($secret_file, $fd_secrets) || die ("Could not open $fd_secrets");
     my $key = "";
-    while(<SECRETS>) {
+    while(<$secret_file>) {
       if ($_ =~ m/RequestHeader set FDKEY ([^ \n]+)\n/) {
         $key = $1;
         last;
       }
     }
-    close(SECRETS);
+    close($secret_file);
     $bind_pwd = cred_decrypt($bind_pwd, $key);
   }
 
   if ($tls) {
     # Read LDAP config file
-    open (LDAPCONF,$vars{ldap_conf}) or die ("! Failed to open ldap config file '$vars{ldap_conf}': $!\n");
+    open ($ldap_conf,$vars{ldap_conf}) or die ("! Failed to open ldap config file '$vars{ldap_conf}': $!\n");
 
     my %tls_options = (
       'REQCERT'   => 'require',
@@ -816,14 +818,14 @@ sub get_ldap_connexion {
       'CACERT'    => '',
     );
     # Scan LDAP config
-    while (<LDAPCONF>) {
+    while (<$ldap_conf>) {
       /^\s*(#|$)/ && next;
       chomp;
       if (m/^TLS_(REQCERT|CERT|KEY|CACERTDIR|CACERT)\s+(.*)\s*$/i) {
         $tls_options{uc $1} = $2;
       }
     }
-    close(LDAPCONF);
+    close($ldap_conf);
 
     $ldap->start_tls(
       verify      => $tls_options{'REQCERT'},
@@ -1952,15 +1954,17 @@ sub set_config_var {
 
 sub show_version {
   my $variables_common_path = "$vars{fd_home}/include/variables_common.inc";
+  my $vars_file;
+
   if (-e $variables_common_path) {
-    open(VARS, $variables_common_path) || die ("Could not open $variables_common_path");
-    while(<VARS>) {
+    open($vars_file, $variables_common_path) || die ("Could not open $variables_common_path");
+    while(<$vars_file>) {
       if ($_ =~ m/^define \(["']FD_VERSION["'], "([^"]+)"\);/) {
         print "FusionDirectory version is $1\n";
         last;
       }
     }
-    close(VARS);
+    close($vars_file);
   } else {
     print "File $variables_common_path does not exists, can’t find out FusionDirectory version\n";
   }