Hey there good monks! I'm writing a small perl script to create 1000 files ("test_set_$i" here) with 400 gene IDs each (one per line). Then I must search for them in 4 other files (stored in @results). I'd rather use unix grep -f instead of doing a lot of Perl open/close and hash creating and accessing, which would be way too slower. The problem comes after iteration #204, in which the backticks call won't get the output in $tot_length and $? gets -1. Any idea why, please? I'm using Perl v5.14.2 in 64-bit Ubuntu 14.04. Here's that part of the code only:
for my $i(0..999){ + + my $tot_length = `grep -f test_set_$i $ARGV[2] | awk '{cnt += \$2}END{printf "%d", +cnt}'`; `grep -f test_set_$i $results[0] | awk '{print \$1}' | sed 's/>>//'| sort | uniq -c | awk '{print \$1*1000/$tot_length,\$2}' > out`; tie @{$files{'first'}[$i]},'Tie::File', "out"; `grep -f test_set_$i $results[1] | awk -F" : " '{print \$2}' | sort | uniq -c| awk '{print \$1*1000/$tot_length,\$2}' > out`; tie @{$files{'second'}[$i]},'Tie::File', "out"; `grep -f test_set_$i $results[2] | sed 's/ targets sites//' | sed 's/.*>//' | awk -F": " '{cnt[\$1]+=\$2} END{for (x in cnt){print cnt[x]*1000/$tot_length,x}}' > out`; tie @{$files{'third'}[$i]},'Tie::File',"out"; `grep -f test_set_$i $results[3] | awk '{print \$2}' | sort | uniq -c| awk '{print \$1*1000/$tot_length,\$2}' > out`; tie @{$files{'fourth'}[$i]},'Tie::File',"out"; `grep -f test_set_$i $results[4] | awk '{print \$2}' | sort | uniq -c| awk '{print \$1*1000/$tot_length,\$2}' > out`; tie @{$files{'fifth'}[$i]},'Tie::File',"out"; }
Thanks a lot!
In reply to Perl backticks not returning output by dannyjmh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |