From b50a560315de756f1bf9ea7da934a4024d7b0157 Mon Sep 17 00:00:00 2001
From: Andrew Yates <ayates@ebi.ac.uk>
Date: Sat, 27 Apr 2013 10:32:59 +0000
Subject: [PATCH] better version of this code I hope

---
 modules/Bio/EnsEMBL/Registry.pm | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Registry.pm b/modules/Bio/EnsEMBL/Registry.pm
index f9ec9e4f28..45c1d2315c 100644
--- a/modules/Bio/EnsEMBL/Registry.pm
+++ b/modules/Bio/EnsEMBL/Registry.pm
@@ -1573,14 +1573,12 @@ sub load_registry_from_db {
   if(! defined $db_version) {
     # Do checking for the -DB_VERSION flag which can be mis-spelt. Regex assembled using:
     # perl -MRegexp::Assemble -e '$r=Regexp::Assemble->new(); $r->add($_) for ("-dbversion","-version","-verion","-verison"); print $r->re, "\n";'
-    my $db_version_flag_re = qr/(?-xism:-(?:ver(?:is?|si)|dbversi)on)/xism;
-    for(my $i = 0; $i < scalar(@args); $i = $i+2) {
-      if($args[$i] =~ $db_version_flag_re) {
-        my $msg = sprintf(q{Detected no -DB_VERSION flag but found '%s'; assuming a mis-spelling. Please fix}, $args[$i]);
-        warning($msg);
-        $db_version = $args[$i+1];
-        last;
-      }
+    my %hashed_args = @args;
+    my ($possible_key) = grep { $_ =~ /(?-xism:-(?:ver(?:is?|si)|dbversi)on)/xism } keys %hashed_args;
+    if($possible_key) {
+      my $msg = sprintf(q{Detected no -DB_VERSION flag but found '%s'; assuming a mis-spelling. Please fix}, $possible_key);
+      warning($msg);
+      $db_version = $hashed_args{$possible_key};
     }
   }
 
-- 
GitLab