Permalink
Browse files

Some cleanup

  • Loading branch information...
1 parent 604223a commit b1963f71a706b22c10aa6ba938c9f09803b2e998 @rgeissert committed Jan 18, 2012
Showing with 12 additions and 6 deletions.
  1. +12 −6 redir.pl
View
@@ -60,6 +60,7 @@
sub calculate_distance($$$$);
sub stddevp;
sub print_xtra($$);
+sub find_arch($@);
my @ARCHITECTURES_REGEX;
@@ -111,12 +112,7 @@
print_xtra('URL', $url);
-foreach my $r (@ARCHITECTURES_REGEX) {
- if ($url =~ m/$r/) {
- $arch = $1;
- last;
- }
-}
+$arch = find_arch($url, @ARCHITECTURES_REGEX);
$arch = 'i386' if ($arch eq 'multi-arch');
print_xtra('Arch', $arch);
@@ -281,3 +277,13 @@ ($$)
print "X-$_[0]: $_[1]\r\n"
if ($xtra_headers);
}
+
+sub find_arch($@) {
+ my $url = shift;
+ local $_;
+
+ foreach (@_) {
+ return $1 if ($url =~ m/$_/);
+ }
+ return '';
+}

0 comments on commit b1963f7

Please sign in to comment.