make first fixed and mobile phone and put in in separate fields
[virtual-ldap] / bin / csv2yaml.pl
index 9d0f9ad..ec9bf4e 100755 (executable)
@@ -42,10 +42,22 @@ foreach my $line ( split(/\r?\n/, $csv) ) {
                my $v = $fields[$_];
 
                $v =~ s{\s*#\s*$}{};
+               $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];
                        }
                }