Welcome to Perl and PerlMonks, PandaRaey!
First, a few general tips:
- It's very good you're using strict and warnings! However, note that pre-declaring your variables at the top of the script like that is not so good, because they are then like global variables. Instead, it's best to declare them at the smallest scope where they are needed. For example, foreach my $folder (@folders) {, while ( my $file = readdir(DIR) ) {, or my $reads = 0;. Skimming your code, I don't see any obvious scoping issues caused by the global variables, but I might have overlooked something.
Please try to use consistent indentation. perltidy can help.
- I would recommend using the more modern three-argument form of open, and lexical filehandles (my $fh instead of bareword filehandles like FILE, since the latter are global). For example: open my $fh, '<', $filename or die "$filename: $!";
- Always check open for errors, which you do on your first open, but not on the second or third.
The last point may even account for your problem, "I do not get the content I should printed into the Merge-File". Another possibility is that you might want to open that file for appending (">>"), because ">" overwrites the file (Update: I just saw that hippo made the same point.).
Other than that, I have looked at your code, and nothing obvious has jumped out at me yet. A few thoughts: You don't seem to be chomping the lines you read from files (removing the newline at the end), and you could use some of the tips from the Basic debugging checklist, like using Data::Dumper to print out the contents of your variables while your program is running (I recommend setting $Data::Dumper::Useqq=1; to see whitespace better). Also, I see you're doing $tRNAname = $line[0]; $tRNAname = $&;, which doesn't make sense to me because the second assignment will just overwrite the first. Other than that, your expected output seems to depend on your data and algorithm.
The problem is that without sample data, we can't really run the code. It would be best if you could provide a Short, Self-Contained, Correct Example, that is, some small sample input that demonstrates your problem, the expected output for that input, and your actual output, including any error messages you might be getting (all within <code> tags). Also a description of what your algorithm is supposed to be doing would help.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.