make first fixed and mobile phone and put in in separate fields
[virtual-ldap] / bin / csv2yaml.pl
index a40eb3e..ec9bf4e 100755 (executable)
@@ -45,9 +45,19 @@ 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];
                        }
                }