Henri772 | Salut j'ai un souci avec ce code il fonctionnait avec d'autres fichiers d'entree j'ai change les fichiers d'entree maintenant il me retourne l'erreur suivante,
j'ai eu a modifier la ligne 63 de la sorte
Code :
print $wh "$colums1{$i} $row->[$i]$data2{$colums1{$i}}\n";
|
ca n'a pas marche
Code :
#!/usr/bin/perl use strict; use warnings; use Text::CSV; use Data::Dumper; my $infile1 = "DATA2.csv"; my $infile2 = "default.csv"; my $csv = Text::CSV->new( { sep_char => ',', allow_whitespace => 1, binary => 1 } ); # open input files open my $csv_1, '<', $infile1 or die "open($infile1,r) failed: $!"; open my $csv_2, '<', $infile2 or die "open($infile2,r) failed: $!"; <$csv_2>; my @columns2 = @{ $csv->getline($csv_2) }; my @values = @{ $csv->getline($csv_2) }; my %data2; for my $i ( 0 .. $#columns2 ) { $data2{$columns2[$i]} = defined $values[$i] ? $values[$i] : ''; } warn Data:: Dumper->Dump ( [ \ %data2 ], [ '*data2' ] ) if $ENV{DEBUG }; my @colums1; while ( my $row = $csv->getline( $csv_1 ) ) { next if 0 == $#{$row}; next if 6 == $#{$row}; my ( $significator, $filename ) = split m{\ s+ }, $row-> [0]; if ( $significator eq 'default' ) { @colums1 = @$row; warn Data:: Dumper->Dump ( [ \ @colums1 ], [ '*columns1' ] ) if $ENV{DEBUG }; } elsif ( $significator eq 'false' ) { warn Data:: Dumper->Dump ( [ $row ], [ '*row' ] ) if $ENV{DEBUG }; open (my $wh, ">", "$filename.csv" ) or die "Can't open per-line file $filename: $!\n"; print $wh "$filename:\n"; for my $i ( 0 .. $#{$row}-1 ) { print $wh "$colums1[$i] $row->[$i]$data2{$colums1[$i]}\n"; } close $wh or die "close($filename,w) failed: $!"; } }
|
Code :
- .pl line 63, <$csv_1> line 127.
- Use of uninitialized value within @colums1 in hash element at new.pl line 63, <$
- csv_1> line 127.
- Use of uninitialized value within @colums1 in concatenation (.) or string at new
- .pl line 63, <$csv_1> line 127.
- Use of uninitialized value within @colums1 in hash element at new.pl line 63, <$
- csv_1> line 127.
- Use of uninitialized value within @colums1 in concatenation (.) or string at new
- .pl line 63, <$csv_1> line 127.
- Use of uninitialized value within @colums1 in hash element at new.pl line 63, <$
- csv_1> line 127.
- Use of uninitialized value within @colums1 in concatenation (.) or string at new
- .pl line 63, <$csv_1> line 127.
- Use of uninitialized value within @colums1 in hash element at new.pl line 63, <$
- csv_1> line 127.
- Use of uninitialized value within @colums1 in concatenation (.) or string at new
- .pl line 63, <$csv_1> line 127.
- Use of uninitialized value within @colums1 in hash element at new.pl line 63, <$
- csv_1> line 127.
- Use of uninitialized value within @colums1 in concatenation (.) or string at new
- .pl line 63, <$csv_1> line 127.
- Use of uninitialized value within @colums1 in hash element at new.pl line 63, <$
- csv_1> line 127.
- C:\Users\Desktop\CAV>
|
|