/[virtual-ldap]/bin/csv2yaml.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/csv2yaml.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 13 by dpavlin, Sun Mar 15 20:47:15 2009 UTC revision 14 by dpavlin, Sun Mar 15 20:54:14 2009 UTC
# Line 45  foreach my $line ( split(/\r?\n/, $csv) Line 45  foreach my $line ( split(/\r?\n/, $csv)
45                  $v =~ s{^\s+}{};                  $v =~ s{^\s+}{};
46                  $v =~ s{\s+$}{};                  $v =~ s{\s+$}{};
47    
48                    # fix tel fields
49                    $v =~ s{\s+}{#}g if $n =~ m{tel};
50    
51                  if ( $v =~ m{#} ) {                  if ( $v =~ m{#} ) {
52                          my @v = split(/\s*#\s*/, $v);                          my @v = split(/\s*#\s*/, $v);
53                          foreach my $pos ( 0 .. $#v ) {                          foreach my $pos ( 0 .. $#v ) {
54                                    if ( $n =~ m{tel} ) {
55                                            if ( $v[$pos] =~ m{^09} ) {
56                                                    $hash->{ $n . '_mobile' } ||= $v[$pos];
57                                            } else {
58                                                    $hash->{ $n . '_fixed' } ||= $v[$pos];
59                                            }
60                                    }
61                                  $hash->{ $n . '_' . $pos } = $v[$pos];                                  $hash->{ $n . '_' . $pos } = $v[$pos];
                                 $hash->{ $n . '_mobitel' } = $v[$pos] if $n =~ m{tel} && $v[$pos] =~ m{^09};  
62                          }                          }
63                  }                  }
64                  $hash->{ $n } = $v;                  $hash->{ $n } = $v;

Legend:
Removed from v.13  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.26