From: Dobrica Pavlinusic Date: Sun, 15 Mar 2009 20:54:14 +0000 (+0000) Subject: make first fixed and mobile phone and put in in separate fields X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=commitdiff_plain;h=d8ce285eb264c426855a012d6afe1b3b613a8452 make first fixed and mobile phone and put in in separate fields --- diff --git a/bin/csv2yaml.pl b/bin/csv2yaml.pl index 4526926..ec9bf4e 100755 --- a/bin/csv2yaml.pl +++ b/bin/csv2yaml.pl @@ -45,11 +45,20 @@ foreach my $line ( split(/\r?\n/, $csv) ) { $v =~ s{^\s+}{}; $v =~ s{\s+$}{}; + # fix tel fields + $v =~ s{\s+}{#}g if $n =~ m{tel}; + if ( $v =~ m{#} ) { my @v = split(/\s*#\s*/, $v); foreach my $pos ( 0 .. $#v ) { + if ( $n =~ m{tel} ) { + if ( $v[$pos] =~ m{^09} ) { + $hash->{ $n . '_mobile' } ||= $v[$pos]; + } else { + $hash->{ $n . '_fixed' } ||= $v[$pos]; + } + } $hash->{ $n . '_' . $pos } = $v[$pos]; - $hash->{ $n . '_mobitel' } = $v[$pos] if $n =~ m{tel} && $v[$pos] =~ m{^09}; } } $hash->{ $n } = $v;