summaryrefslogtreecommitdiff
path: root/bin/efa
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-01-03 19:29:42 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2010-01-03 19:29:42 +0100
commita7eca51b8e19d68790cae86a93bd95f45c176b92 (patch)
treed3d7074083fea6340bcdffea2d780a0262ca9f7e /bin/efa
parenta50988cabac22dd3a86cd4fc3fa0d99126af0988 (diff)
More code reuse
Diffstat (limited to 'bin/efa')
-rwxr-xr-xbin/efa32
1 files changed, 11 insertions, 21 deletions
diff --git a/bin/efa b/bin/efa
index a0af148..0d4cdfa 100755
--- a/bin/efa
+++ b/bin/efa
@@ -241,27 +241,17 @@ if (@to != 2 or @from != 2) {
exit 1;
}
-# TODO: More code reuse here
-
-if ($from[1] =~ s/ ^ addr: \s* (.+) $ /$1/x) {
- $from_type = 'address';
-}
-elsif ($from[1] =~ s/ ^ poi: \s* (.+) $ /$1/x) {
- $from_type = 'poi';
-}
-
-if (defined $via[1] and $via[1] =~ s/ ^ addr: \s* (.+) $ /$1/x) {
- $via_type = 'address';
-}
-elsif (defined $via[1] and $via[1] =~ s/ ^ poi: \s* (.+) $ /$1/x) {
- $via_type = 'poi';
-}
-
-if ($to[1] =~ s/ ^ addr: \s* (.+) $ /$1/x) {
- $to_type = 'address';
-}
-elsif ($to[1] =~ s/ ^ poi: \s* (.+) $ /$1/x) {
- $to_type = 'poi';
+for my $pair (
+ [$from[1], \$from_type],
+ [$via[1] , \$via_type ],
+ [$to[1] , \$to_type ],
+) {
+ next if (not defined $pair->[0]);
+ for my $type (['addr', 'address'], ['poi', 'poi']) {
+ if ($pair->[0] =~ s/ ^ $type->[0] : \s* (.+) $ /$1/x) {
+ ${$pair->[1]} = $type->[1];
+ }
+ }
}
@post{'place_origin', 'name_origin'} = @from;