
October 11th, 2012, 05:03 PM
|
|
|
Hi,
follow the instructions.
Quote: | a. Remove the code that creates a file with numbered lines |
You did not remove that code, as far as I can say.
Quote: | b. Using backtics, run the command `grep JAY291 $file.blastn` and capture the results of the grep in an array |
Your try:
Perl Code:
Original
- Perl Code |
|
|
|
` grep JAY291 $file.blastn` > my @grep_results
You can't redirect output in Perl the same way as you would do in a shell script. The backticks command returns the result of the system command.
Try something like this:
Perl Code:
Original
- Perl Code |
|
|
|
my @grep_result = ` grep JAY291 $file.blastn`;
Here is an example of a Perl one-liner where I look for all instances of the "use" word in the Perl files of my current directory:
Perl Code:
Original
- Perl Code |
|
|
|
perl -e '@foo = `grep use *.pl`; chomp @foo; print "$_\n" foreach @foo;'
This is part of the output:
Code:
filter.pl:use 5.10.0;
filter.pl:use strict;
filter.pl:use warnings;
genetic.pl:use strict;
genetic.pl:use warnings;
genetic2.pl:use strict;
genetic2.pl:use warnings;
genetic3.pl:use strict;
genetic3.pl:use warnings;
Then, you need to go through each element of your @grep_result array. Something like this:
Perl Code:
Original
- Perl Code |
|
|
|
foreach my $line (@grep_result) { # ...
I'll leave it there, as this is obviously homework assignment, you should probably try to figure out the rest by yourself.
|