I'm constantly amazed that people (try to) work with source code which looks like that. I've done only two things to it:

  1. Removed all the commented-out lines which aren't comments with perl -ni -e 'print unless /^\s*#[^#!]/;' 1141288.pl
  2. Run it through perltidy to sort out the indenting

The resulting code is here:

#!/usr/bin/env perl use strict; use warnings; my @a; my $n = "\n"; @a = glob ("*.Recip.blast.top"); my $t = "\t"; foreach my $a (@a) { my @b = split (/[.]/, $a); my $OrginalBlast; $OrginalBlast = $b[0] . "." . $b[1] . "." . $b[2] . "." . $b[3] . "." . $b[4] . "." . $b[5] . "." . $b[6] . "." . $b[7]; #####ORGN is = AB||||||| open (ORGN, "/home/ajl12013/Labwork/Dbfiles/results/$OrginalBlast" +) || die; ######RECI is = BA||||||| open (RECI, $a) || die; open (OUTM, ">MatchingGI.txt") || die; open (OUTNoM, ">NoMatchingGI.txt") || die; my $ORGN = <ORGN>; my $RECI = <RECI>; my %GenomeTable; my $Genome1A; my $G1A; my $data; my $G2A; my $Genome2A; my $l; local $/; my $key; $GenomeTable{$OrginalBlast} = $a; #### First while statement for the AB file. $GenomeTable{$n} = $n; while (my $G1A = <ORGN>) { if ($G1A =~ m/^[gi|]\w/) { ($Genome1A) = $G1A =~ m/^gi\|\d+/g; $GenomeTable{$Genome1A} = []; $GenomeTable{$n}; foreach my $keys (keys %GenomeTable) { print " Keys: $keys + $n"; } } while ($G2A = $RECI) { if ($G2A =~ m/^[gi|]/) { $G2A =~ m/^gi\|\w+\|\w+\|\w+\.\d\|\w+\s(gi\|\d+)/g; $Genome2A = $1; $GenomeTable{$Genome1A} = $Genome2A; foreach my $values (values %GenomeTable) { print "Values: $values $n"; } $Genome1A eq $Genome2A ? print OUTM $a . $n : print OUTNoM $a . $n; } } } }

From this the overall structure of the code is much more apparent to me. Now you can think about applying the other excellent suggestions already given by my learned brethren.

It would also be useful to know which version of Perl you are using when it comes to actually solving your problem.


In reply to Re: How to do a reciprocal matching statement by hippo
in thread How to do a reciprocal matching statement by ajl412860

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.