in reply to regular expression questions (from someone without experience)

Wow, that's a beast of a results file. At the moment, you are not using regular expressions at all. Without going in detail through this massive text file I can't give you the exact regexes but what you need to do is write down (and maybe post here if you need more help) what exactly a new block starts and ends with. This will help you to identify a pattern. Say you have a file like this:

miRNA1a - results SOME DATA HERE ####### results end ######### miRNA2 - results ... and so on
Then you could do:
while (<>){ chomp; if (/^(miRNA\w+) - results/){ my $mirna_id = $1; while (<>){ chomp; last if /^####### results end #########/; # PARSE YOUR DATA HERE } } }
There are of course other ways of doing this but this should work for you. You just need to identify the patterns that signal the beginning and end of a block.

UPDATE

Actually, I think this may be even better for you: since you are probably parsing the same data for different microRNAs, all you need to do is keep track of which microRNA you are reading the data for at the moment. So, still using my above example text file, I would do:

my $current_mirna; while(<>){ chomp; $current_mirna = $1 if /^(miRNA\w+) - results/; die unless defined $current_mirna; # now you always have the miRNA ID of the current block # conitnue here to parse the actual data and insert into the # database for that specific miRNA }