Update: this post uses the observations of missing semi-colons and unmatched quotes in previous replies but is intended to criticize the original post Getting an unknown error when it employs the second person.
It would seem evident that this script never ran, with the missing semi-colons and troubled declaration of @ptt. When you're struggling with syntax, start with what compiles and behaves well and make revisions as you near your goal. Download Perl::Tidy using cpan or apt-get to gussy it up before sharing it with the monastery.
$ perltidy -b -i=2 gene3.pl To make this program work, there must be some type of data to read in. It doesn't take too much effort to seed it with some values for testing purposes:
$ cat scaffold_contig.txt
this>that
5>10
$
I prefer to use the say feature, which one gets by use 5.010;. It obviates having to paste newlines on the ends of print statements and makes seeing the contents of an array a cinch:
$ perl gene3.pl
ptt is O P Q R S T U V W X Y Z
line 0 is this>that
line 1 is 5>10
lines are this>that 5>10
$ cat gene3.pl
use strict;
use warnings;
use 5.010;
my @Genes = qw(A B C D);
my @ptt = ( 19384 .. 3059, "O" .. "A" ); #what is this supposed
+to be?
my @contig = ();
my @Coordinates;
my @Number;
my $R;
say "ptt is @ptt";
foreach my $G (@Genes) {
for my $x ( 0 .. $#ptt ) {
if ( $ptt[$x] =~ /$G/ ) {
push( @Coordinates, "$ptt[$x]" );
print "$ptt[$x]\n";
}
}
}
foreach my $C (@Coordinates) {
push( @Number, split( " ", $C ) );
}
my %hash = ();
my $file = "scaffold_contig.txt";
open( IN, "<$file" ) or die "Cannot open file $file\n";
my @lines = <IN>;
foreach (@lines) {
chomp();
my %columns = split( ">", $_ );
# nothing happens with %columns and then the scope changes
}
close(IN);
say "line 0 is $lines[0]";
say "line 1 is $lines[1]";
say "lines are @lines";
foreach my $N (@Number) {
for $R ( 0 .. $#lines ) {
if ( $lines[$R] =~ /$N/ ) {
print "lines[$R]\n";
}
}
}
$
I'd be very interested to see what this looks like as code that performs to specification. Good luck. |