Dear programmer(s),
Could you please tell me why the below script runs infinitely ? How can I print the result only once?
#!/usr/local/bin/perl -w
use strict;
open (file1, $ARGV[0]);
my $gene;
my $rs;
my $tf;
my $ds;
my %gene_key;
my @genes;
while(<file1>){
if ($_=~/^(.+)\t+(.+)\t+(.+)\t(.+)$/){
$gene=$1;
$rs=$2;
$tf=$3;
$ds=$4;
}
push (@genes, $gene);
foreach $gene (@genes){
$gene_key{$gene}=($3." ".$2." ".$4);
}
foreach $gene(keys %gene_key){
my @gene_table;
push (@gene_table, $gene," ",$gene_key{$gene});
print "$gene.' '.$gene_key{$gene}";
}
}
close (file1);
Regards,
szzxy
Could you please tell me why the below script runs infinitely ? How can I print the result only once?
#!/usr/local/bin/perl -w
use strict;
open (file1, $ARGV[0]);
my $gene;
my $rs;
my $tf;
my $ds;
my %gene_key;
my @genes;
while(<file1>){
if ($_=~/^(.+)\t+(.+)\t+(.+)\t(.+)$/){
$gene=$1;
$rs=$2;
$tf=$3;
$ds=$4;
}
push (@genes, $gene);
foreach $gene (@genes){
$gene_key{$gene}=($3." ".$2." ".$4);
}
foreach $gene(keys %gene_key){
my @gene_table;
push (@gene_table, $gene," ",$gene_key{$gene});
print "$gene.' '.$gene_key{$gene}";
}
}
close (file1);
Regards,
szzxy