in reply to Re^3: foreach loop
in thread foreach loop

Thanks. This seem to work with the print. It appears to me though that the print is done after each iteration. Is there a way to retain the values of @chr and $sequence for each iteration so that they can be accessed outside the foreach loop? The data am dealing with is actually nnnnnnnnn i.e an fq sequence file and what am showing here is just part of it.
_DATA_ @chr1 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn @chr2 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn @chr4 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn @chr5 nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn

Replies are listed 'Best First'.
Re^5: foreach loop
by ww (Archbishop) on May 04, 2011 at 21:00 UTC
    Of course there is!

    This is Perl.

    However, to learn how to do so (we are here, after all, to help you learn, not to do it for you), I would suggest push. Using the example there, you could create an array with elements 0, 2, 4 ... containing the "@char\d" and the odd-numbered elements with the data. Alternately (and perhaps better), see the Tutorials on hashes, here in the Monastery
        ...just for starters, that is.