Here's a start, since you've not (yet?) replied to Kenosis' very proper request that you show us what you've tried (and how it failed to satisfy your needs, with error and warning messages, verbatim) as tokens of good faith that you're here to learn; not simply to have others do your work:

#!/usr/bin/perl use 5.016; use warnings; # 1068826 my $data = '>b_comp_seq1 ACGCGGGGGAATTT >b_comp_seq2 ACGGAATT >b_comp_ +seq3 GGGGGCTTTCACC >b_comp_seq4 TACCGGGAATT'; my @data1 = split /\s/, $data; my $i=0; my ($data1, $fh, $fn); for $_(@data1) { $_ =~ />(.*)/; $fn = $1; if ( $i%2 == 0 ) { open $fh, ">", $fn or warn "Can't open $fh for write, $!"; ++$i; print $fh "$fn \t $data1[$i]"; say " DEBUG: \$fn, \$data1[$i]: $fn, $data1[$i]"; close $fh; } else { ++$i; #ALSO -- # consider how to revert to writing to the first file for comp +_seq_5 # if that's the way you wish to order the elements; otherwise, + revise # the code above to put the first four sequences and their sou +rce # id's into the first file written. } } =head output files contain... b_comp_seq1 ACGCGGGGGAATTT b_comp_seq2 ACGGAATT b_comp_seq3 GGGGGCTTTCACC b_comp_seq4 TACCGGGAATT =cut

Left as a challenge for crayfish: adding sequences (and identifiers?) to the four files created here. Hint: hashes might be one way to go.


If you didn't program your executable by toggling in binary, it wasn't really programming!


In reply to Re: separate files by ww
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.