Hi,
I am quite new to perl scripting.
I have a dat file (datFile) from which I am pulling only first column and saving the output to a new file (f). From that file (f) I am removing blank lines and saving it to new file (datFile1). I am able to get the count of $f file in variable $cnt. But I am unable to get the count of $datFile1 in $cnt1.
Please find below my code.
my $cnt;
my $cnt1;
my $f = $datFile."_Column.dat";
my $datFile1= $datFile."_null.dat";
open my $fh_in, "<", "$datFile" or die "Could not open $datFile: $!\n";
open my $fh_out, ">", "$f" or die "Could not create $f: $!\n";
while ( my $line = <$fh_in> ) {
my $first_column = (split /\t/, $line)[0];
print $fh_out "$first_column\n";
}
close $fh_in;
close $fh_out;
open my $fh_in1, "<", "$f" or die "Could not open $f: $!\n";
open my $fh_out1, ">", "$datFile1" or die "Could not create $datFile1: $!\n";
while ( <$fh_in1> ) {
if (/\S/) {
print $fh_out1 $_;
}
}
open(FH,$datFile) or die "Damn. $!";
$cnt++ while <FH>;
close FH;
print "$cnt\n";
open(FHN,$datFile1) or die "Damn. $!";
$cnt1++ while <FHN>;
close FHN;
print "$cnt1\n";
$logger->info($ID." ".$cnt." Check count cnt");
$logger->info($ID." ".$cnt1." Check count cnt1");
Regards
Neethu