I can't figure out what is wrong with my code. It's supposed to create an array and print it out, but nothing prints, I don't get any error messages or anything.
Here is my code:
while (<>) {
chomp;
push @isr, [split/\t/];
}
for my $i(0..$#isr){
if ($isr[$i][5] eq "10"
{
push @trialtype1, $isr[$i][3];
}
}
print @trialtype1;
Basically it reads a data file that looks something like this:
1 287 3 123456 ABBABA 90
1 287 3 123456 ABBABA 90
1 30 9 123456 ABBBAA 100
1 55 5 125346 ABBAAB 80
1 55 5 125346 ABBAAB 80
1 285 2 651234 BABAAB 70
1 224 1 641253 ABABAB 60
1 204 5 612435 BAABBA 80
1 204 5 612435 BAABBA 80
1 204 5 612435 BAABBA 80
1 204 5 612435 BAABBA 80
1 204 5 612435 BAABBA 80
1 113 4 231456 AABBAB 30
1 113 4 231456 AABBAB 30
1 234 6 243156 BBABAA 20
1 234 6 243156 BBABAA 20
1 227 10 164253 BBBAAA 10
1 184 10 143256 AAABBB 10
1 184 10 143256 AAABBB 10
1 184 10 143256 AAABBB 10
1 84 3 124365 BAABAB 90
1 84 3 124365 BAABAB 90
So my codes takes each lines and puts each number or "word" into a separate element in the array. The elements I am currently interested are the [3] and [5] positions on each row.
What I want to do is look for the ones that contain a 10 in position [5] and put just the [3] element of that line into another array. Then print it out. However, it doesn't seem to be working since nothing is printed out.
I'm using eq instead of == because for some reason it thinks its not a number, but I don't see how that should make a difference.
Here is my code:
while (<>) {
chomp;
push @isr, [split/\t/];
}
for my $i(0..$#isr){
if ($isr[$i][5] eq "10"
push @trialtype1, $isr[$i][3];
}
}
print @trialtype1;
Basically it reads a data file that looks something like this:
1 287 3 123456 ABBABA 90
1 287 3 123456 ABBABA 90
1 30 9 123456 ABBBAA 100
1 55 5 125346 ABBAAB 80
1 55 5 125346 ABBAAB 80
1 285 2 651234 BABAAB 70
1 224 1 641253 ABABAB 60
1 204 5 612435 BAABBA 80
1 204 5 612435 BAABBA 80
1 204 5 612435 BAABBA 80
1 204 5 612435 BAABBA 80
1 204 5 612435 BAABBA 80
1 113 4 231456 AABBAB 30
1 113 4 231456 AABBAB 30
1 234 6 243156 BBABAA 20
1 234 6 243156 BBABAA 20
1 227 10 164253 BBBAAA 10
1 184 10 143256 AAABBB 10
1 184 10 143256 AAABBB 10
1 184 10 143256 AAABBB 10
1 84 3 124365 BAABAB 90
1 84 3 124365 BAABAB 90
So my codes takes each lines and puts each number or "word" into a separate element in the array. The elements I am currently interested are the [3] and [5] positions on each row.
What I want to do is look for the ones that contain a 10 in position [5] and put just the [3] element of that line into another array. Then print it out. However, it doesn't seem to be working since nothing is printed out.
I'm using eq instead of == because for some reason it thinks its not a number, but I don't see how that should make a difference.