Without already being able to give you a solution, I have the following comments:

  1. Just a style argument: why do you put the subs definitions in the middle of your code? It tends to make the structure a lot less easy to read.
  2. spliceing the first two items of your array with filenames/directories, is a nice trick if you can be sure that the first two items are always the dot and dot-dot items. This may be something which is not guaranteed and/or not portable across all OS.
  3. Your program assumes (as is your good right) a very specific directory and file-structure (top level only holds directories and each such directory contains a "data"-file. Which makes it difficult to test your script if one doesn't have the same structure.
  4. get_targets and get_signal, seems to go through the same "data"-file, just extracting different items, resp. extracting the first and the fourth item and saving the rest in some variables which are never used (if you did use warnings you would have received some warnings in this respect). The same goes for the variables $scratch, $excess and $spliced_data, which are essentially just garbage bins in your script.
  5. Rather than using global variables, you could pass to your subs an argument list. If you did that then you would really see that you are using the same arguments in both subroutines. Now you use @genius and @filename, which are just copies of each other, but that is not readily apparent.
  6. What you are trying to do with %hash={"$file"=>@final_data} beats me. Could you explain it?
  7. Why do you return the value of @targets to @columns? You never ever use the @columns-array?
  8. Why did you think @$i=@next_columns[$i] would work? Can you explain your reasoning behind it?
About the "unique variable name" thing: why would you need that? I'm not convinced that it is necessary for your purpose. May I suggest that you give us an example of your inputs and your expected output? That would make it a lot easier to help you.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law


In reply to Re: Unique Variable names... by CountZero
in thread Unique Variable names... by bioinformatics

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.