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.


In reply to Re^2: Getting an unknown error by Aldebaran
in thread Getting an unknown error by andybshaker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.