Dude, you are really coming across as being profoundly clueless. This thread is seventh one you've started on this same basic programming task. (For those keeping score, the previous six, in chronological order, are: Regex problem, Extracting Locations in 3 window size, Debug help, Character replacement, Missing to catch 70th character in 3 window size, and Multiple Key Problem help.)

A common attribute of all these threads is that you have never given a clear description of what you are really trying to accomplish. What exactly are the specs for this job? When you say:

I want my Output should be like this:-
155369268 17 CTA 155369268 70 CGA 269212605 120 TTG

HOW DO YOU KNOW that this is what the output should be? What are the principles for determining what the program is supposed to locate in these files? If you can form a clear, unambiguous answer to that question (in the form of a "cookbook recipe"), it will be a lot easier to get the program to do what is needed.

I'm actually somewhat skeptical about the particular values you are citing here as the "desired" output. Where is the "120" supposed to come from, given that File1.txt does not contain this number?

As for the particular version of noise you've added in this OP to code that others have suggested to you, I don't understand why you have added a "$ref" variable in this while loop:

while (<$fh>) { chomp; my ($key, $pos) = split /\s+/; if (!$positions{$key}) { $positions{$key} = [$pos]; } else { my $ref = $positions{$key}; push @$ref,$pos; } }
(I have undone your randomization of the white-space and indentation.) So, you apparently do not realize that the "else" block there does nothing at all except to push an element onto an array ref, which then goes out of scope (disappears completely, ceases to exist) when you step out of that "else" block. I also don't understand why you are using array refs at all in this while loop.

I think it's time for you to confess that you really don't understand what you are trying to do, let alone what you are actually doing. If it's important for this job to get done, someone else is going to have to do it. Go to your supervisor or advisor or other knowledgeable person who can speak to you face-to-face, and admit to them that you are lost.

It looks like the kind of help you need is not the kind of help you can get from perlmonks.


In reply to Re: Hashs of hash (multiple value) key problem. by graff
in thread Hashs of hash (multiple value) key problem. by ashnator

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.