What's wrong with this perl script?

Steven

New member
I'm writing a perl script that takes the numerical data from the second column of a 5 column data set and then uses the numbers in that column to extract the characters at those particular positions. For example:

The first data set consists of:

1 2 A G 0.5
1 4 G A 0.8
1 6 T C 0.9

The second consists of:

ATCGATCGTCG

The desired result is this data set (the characters at positions 2, 4, and 6 as shown by the second column of the first data set):

T
G
T

This is my script as of now:

#!/usr/bin/perl
my @array;
open(my $FH, 'file/location') or die "$!";
while(<$FH>){
push @array, (split(/\t/))[1];

open(my $file, 'file/location') or die "$!";
}
$protein = substr($file, $array-1, $array-1);
print "$protein";

How can I edit this to fit my requirements?
 
There are so many things wrong with that program that it's hard to know where to start. I strongly recommend you get a good book on Perl and do some studying before trying to write any more code - you can't just haphazardly throw stuff together without understanding what it does and have any realistic chance of getting it to work.
 
Back
Top