G'day crayfish,

Welcome to the monastery.

As already pointed out in previous replies (and a private message), there's a number of problems with what you've posted that makes it difficult for us to know exactly what you need help with.

You've presented your data as a string. Delving into the HTML source, I see it's actually formatted into a number of records. choroba sent you a private message about <code>...</code> tags; if you don't know how to update your post, see "How do I change/delete my post?".

In addition to the formatting of the data, there's potentially a problem with its accuracy. Note "seq1" (without underscore) and "seq_2" (with underscore). I'll leave you to fix that, if necessary.

Your description of the required output is also somewhat vague. For instance, did you want all, some or none of the ">b_comp_..." headers included? It's much better to provide a small example of what you're expecting.

Please read the guidelines in "How do I post a question effectively?". If you post a question with all the appropriate information, you're likely to get good answers in (generally) a short space of time. You might also like to look at "How (Not) To Ask A Question" which explains, in more detail, some of the issues with your original post.

The following code presents techniques that may be suitable for your current needs. It's intentionally generic because, as stated, it's unclear exactly what you want.

#!/usr/bin/env perl use strict; use warnings; my ($group_size, $group) = (2, 0); local $/ = "\n>"; while (<DATA>) { print '*** Filename: XYZ_', ++$group, "\n" unless ($. - 1) % $grou +p_size; chop; print '>' unless $. == 1; print; } print "\n"; __DATA__ >b_comp_seq1 ACGCGGGGGAATTT >b_comp_seq_2 ACGGGCTTTCACC >b_comp_seq3 ACGCGGGGGAATTT >b_comp_seq_4 ACGGGCTTTCACC

Output:

*** Filename: XYZ_1 >b_comp_seq1 ACGCGGGGGAATTT >b_comp_seq_2 ACGGGCTTTCACC *** Filename: XYZ_2 >b_comp_seq3 ACGCGGGGGAATTT >b_comp_seq_4 ACGGGCTTTCACC

Finally, I don't know what expertise you have with Perl. A good starting point for reference documentation is perldoc.perl.org: it begins with an introduction, tutorials and FAQs; more in-depth discussions of topics follow. When you've actually written some code, feel free to ask about any specific difficulties you encounter.

-- Ken


In reply to Re: separate files by kcott
in thread separate files by crayfish

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.