Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

The issue was that the Amp variable, when compared to the size of the others, would go OOB due to the way the $ID was referenced.

I fixed up the code by assigning a separate array for the variable, and then using a loop, like so

my @Amp = (); #Setting up a dynamic Array due to changes in amounts of + possible cell ID's my @Amps = (); #Setting up a dynamic array for the sequences under the + IDs my $n = (0); #Array spacer. Not a local variable; used later in execu +tion. my $file2 = shift; open (FILE2, "$file2")|| die "Failed to open $file2 for reading : $!"; + # Open first file local $/= ">"; my $first=<FILE2>; while (<FILE2>) { # Reading first hash chomp; my ($ID, $Seq) = split("\n"); $Amp[$n] = $ID; #Only need the ID. Sequence can be added to a dif +ferent array in a similar fashion $Seq =~ tr/acgt/ACGT/; $Amps[$n] = $Seq; #As Above, but the sequence $n++; #Increases array holder } close FILE2 || die "Failed to close $file2 : $!"; ... ... my $m = (0); #New variable to check against Amp while ($m < $n){ #while there remain more Amp ID's to check. Not usin +g <= due to how array and perl interact. foreach my $ID (keys %bwa){ #for each ID ... } $m++; }

I realize this isn't the prettiest solution, but its worked well enough with only two different "$ID" strings in input 2. If any monks know of a neater solution, please go ahead =)

In reply to Re: Matching strings from three files (three hashes) by bluecompassrose
in thread Matching strings from three files (three hashes) by FluffyBunny

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (4)
    As of 2020-10-26 08:04 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (250 votes). Check out past polls.