/[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 20 by dpavlin, Mon Mar 16 09:58:36 2009 UTC revision 21 by dpavlin, Mon Mar 16 10:02:46 2009 UTC
# Line 49  foreach my $line ( split(/\r?\n/, $csv) Line 49  foreach my $line ( split(/\r?\n/, $csv)
49                  $v =~ s{\s+}{#}g if $n =~ m{tel};                  $v =~ s{\s+}{#}g if $n =~ m{tel};
50                  $v =~ s[\x{17d}][F] if $n =~ m{spol};                  $v =~ s[\x{17d}][F] if $n =~ m{spol};
51    
52                  if ( $v =~ m{#} ) {                  if ( $v =~ m{#} ) { # subfields delimiter in CSV data
53                          my @v = split(/\s*#+\s*/, $v);                          my @v = split(/\s*#+\s*/, $v);
54                          foreach my $pos ( 0 .. $#v ) {                          foreach my $pos ( 0 .. $#v ) {
55                                  if ( $n =~ m{tel} ) {                                  if ( $n =~ m{tel} ) {
# Line 61  foreach my $line ( split(/\r?\n/, $csv) Line 61  foreach my $line ( split(/\r?\n/, $csv)
61                                  }                                  }
62                                  $hash->{ $n . '_' . $pos } = $v[$pos];                                  $hash->{ $n . '_' . $pos } = $v[$pos];
63                          }                          }
64    
65                            $hash->{ $n } = [ @v ];
66                    } else {
67                            $hash->{ $n } = $v;
68                  }                  }
                 $hash->{ $n } = $v;  
69          }          }
70    
71          warn dump( $hash ) if $debug;          warn dump( $hash ) if $debug;

Legend:
Removed from v.20  
changed lines
  Added in v.21

  ViewVC Help
Powered by ViewVC 1.1.26