/[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 9 by dpavlin, Sun Mar 15 19:45:44 2009 UTC revision 12 by dpavlin, Sun Mar 15 20:39:55 2009 UTC
# Line 37  foreach my $line ( split(/\r?\n/, $csv) Line 37  foreach my $line ( split(/\r?\n/, $csv)
37    
38          warn "# fields = ",dump( @fields ) if $debug;          warn "# fields = ",dump( @fields ) if $debug;
39    
40          $hash->{ $columns[$_] } = $fields[$_] foreach ( 0 .. $#fields );          foreach ( 0 .. $#fields ) {
41                    my $n = $columns[$_];
42                    my $v = $fields[$_];
43    
44                    $v =~ s{\s*#\s*$}{};
45                    $v =~ s{^\s+}{};
46                    $v =~ s{\s+$}{};
47    
48                    if ( $v =~ m{#} ) {
49                            my @v = split(/\s*#\s*/, $v);
50                            foreach my $pos ( 0 .. $#v ) {
51                                    $hash->{ $n . '_' . $pos } = $v[$pos];
52                            }
53                    }
54                    $hash->{ $n } = $v;
55            }
56    
57          warn dump( $hash ) if $debug;          warn dump( $hash ) if $debug;
58    

Legend:
Removed from v.9  
changed lines
  Added in v.12

  ViewVC Help
Powered by ViewVC 1.1.26