I'm learning perl from a book and I'm a bit at lost.
here is my problem:
as you may have guessed, I'm trying to read from this text file into an array and extract the "exon" value and the corresponding name from the file and print it to another file. So far I was able to match value pair by doing the split operation and I was able to setup a key{}. My problem is that only one value pair is produced when I execute the code. I have tried several ways of doing a loop but they either fail or produce the same result. I have tried pattern matching and using the grep command, but nothing came out of. maybe I'm doing this all wrong . Any help would be appreciated.
Here is my data:
Mike 3093 3132 R promoter
John 3500 3912 R disease_locus
Jake 2727 2776 R transposon
sunn 2519 2536 F disease_locu
rich 1969 2310 R exon
Jenn 3788 4369 R exon
Joan 3865 4131 F exon
Here is my code :
open FILE, "C:/sent_data.txt";
while (<FILE>) {
@x= split;
@name{$x[4]} = $x[0];}
$geneToFind = shift @ARGV; {
print "Gene: $geneToFind\n";
print "Name: ", $name{$geneToFind}, "\n";
}
here is my problem:
as you may have guessed, I'm trying to read from this text file into an array and extract the "exon" value and the corresponding name from the file and print it to another file. So far I was able to match value pair by doing the split operation and I was able to setup a key{}. My problem is that only one value pair is produced when I execute the code. I have tried several ways of doing a loop but they either fail or produce the same result. I have tried pattern matching and using the grep command, but nothing came out of. maybe I'm doing this all wrong . Any help would be appreciated.
Here is my data:
Mike 3093 3132 R promoter
John 3500 3912 R disease_locus
Jake 2727 2776 R transposon
sunn 2519 2536 F disease_locu
rich 1969 2310 R exon
Jenn 3788 4369 R exon
Joan 3865 4131 F exon
Here is my code :
open FILE, "C:/sent_data.txt";
while (<FILE>) {
@x= split;
@name{$x[4]} = $x[0];}
$geneToFind = shift @ARGV; {
print "Gene: $geneToFind\n";
print "Name: ", $name{$geneToFind}, "\n";
}