Hi,
I am having problems with a script that should write out to a file. Weird enough the file is generated but it's just empty.. I have tried to write out to terminal and that works fine.. I have tried a much simpler script to write out to a file and that works fine too... I am missing something small, but just can't put my finger on it.. Would really appreciate any help.
Below are the parts of the code that are relevant:
I am having problems with a script that should write out to a file. Weird enough the file is generated but it's just empty.. I have tried to write out to terminal and that works fine.. I have tried a much simpler script to write out to a file and that works fine too... I am missing something small, but just can't put my finger on it.. Would really appreciate any help.
Below are the parts of the code that are relevant:
Code:
#!/usr/bin/env perl
use warnings;
use strict;
use Data::Dumper;
...
open my $ifh, "xref-unip_only.HUMAN.csv" or die "could not open input file $!";
open my $ofh,">ref_table.txt" or die "could not open output file $!";
while(<$ifh>){
$num_read++;
my $line = $_;
my $new_line;
chomp($line);
my ($up_id, $up_short, $ipi, $suppl, $gene) = split(/\t/, $line);
$up_id = substr(substr($up_id,1),0,-1);
$ipi = substr(substr($ipi,1),0,-1);
my $kegg;
eval{$kegg = acquire_kegg($serv, $up_short);};# try getting kegg_id
if($@){...}
if ($kegg ne ""){
my ($up, $kegg_id, $comm) = split(/\t/, $kegg);
$new_line = "$ipi\tup:$up_id\t$kegg_id";
$num_written++; # id converted to KEGG
}
else{$new_line = "$ipi\tup:$up_id\t$kegg";}
print $ofh "$new_line\n";
# print "$new_line\n";
}
close $ifh;
close $ofh;
sub acquire_kegg {...}