X-Git-Url: http://git.rot13.org/?p=virtual-ldap;a=blobdiff_plain;f=bin%2Fcsv2yaml.pl;h=ec9bf4e17a657a7aa902f8a73ada7e4184d2d74f;hp=9d0f9adcce779d80170e40057ff7736f4e0611e2;hb=d8ce285eb264c426855a012d6afe1b3b613a8452;hpb=73a02aada2b34206f7780a4dcdfaed9dd566cda0 diff --git a/bin/csv2yaml.pl b/bin/csv2yaml.pl index 9d0f9ad..ec9bf4e 100755 --- a/bin/csv2yaml.pl +++ b/bin/csv2yaml.pl @@ -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]; } }