История изменений
Исправление WinLin2, (текущая версия) :
#!/usr/bin/perl
use strict;
###
my $file_red = './winequality-red.csv';
my $file_white = './winequality-white.csv';
my $file_out = './result.csv';
###
my $first = 1;
open( my $fout, ">", $file_out ) or die $!;
add_file( $file_red, 'red' );
add_file( $file_white, 'white' );
close $fout;
sub add_file {
my $namefile = shift;
my $type = shift;
open( my $fh, "<", $namefile ) or die $!;
if ( $first ) {
print $fout '"type";' . <$fh>;
$first = 0;
}
while ( my $line = <$fh> ) {
my @ar_line = split( ';', $line );
my $alcohol = $ar_line[10];
my $quality = $ar_line[11];
if ( $alcohol > 10 && $quality > 6 ) {
print $fout "$type;$line";
}
}
close $fh;
return;
}
1;
Исправление WinLin2, :
#!/usr/bin/perl
use strict;
###
my $file_red = './winequality-red.csv';
my $file_white = './winequality-white.csv';
my $file_out = './result.csv';
###
my $first = 1;
open( my $fout, ">", $file_out ) or die "Can't create file: $!";
add_file( $file_red, 'red' );
add_file( $file_white, 'white' );
close $fout;
sub add_file {
my $namefile = shift;
my $type = shift;
open( my $fh, "<", $namefile ) or die "Can't open file: $!";
if ( $first ) {
print $fout '"type";' . <$fh>;
$first = 0;
}
while ( my $line = <$fh> ) {
my @ar_line = split( ';', $line );
my $alcohol = $ar_line[10];
my $quality = $ar_line[11];
if ( $alcohol > 10 && $quality > 6 ) {
print $fout "$type;$line";
}
}
close $fh;
return;
}
1;
Исходная версия WinLin2, :
#!/usr/bin/perl
use strict;
###
my $file_red = './winequality-red.csv';
my $file_white = './winequality-white.csv';
my $file_out = 'result.csv';
###
my $first = 1;
open( my $fout, ">", $file_out ) or die "Can't open file: $!";
add_file( $file_red, 'red' );
add_file( $file_white, 'white' );
close $fout;
sub add_file {
my $namefile = shift;
my $type = shift;
open( my $fh, "<", $namefile ) or die "Can't open file: $!";
if ( $first ) {
print $fout '"type";' . <$fh>;
$first = 0;
}
while ( my $line = <$fh> ) {
my @ar_line = split( ';', $line );
my $alcohol = $ar_line[10];
my $quality = $ar_line[11];
if ( $alcohol > 10 && $quality > 6 ) {
print $fout "$type;$line";
}
}
close $fh;
return;
}
1;