Hi Monks,

I have a text file that looks like this:
0.000000 #need to delete this line
0.000000 0.000000 0.000000 ..256 elements
0.000000 0.000000 0.000000 17.962402 10.630810 ..256 elements
repeats....

Question1: How can I separate every other 256 element into a new text file and leave a blank line or space between each 256 element?

Question2: How do I get rid of that pesky first line at the beginning of the text file: "0.000000 "

Here is how I started:

#!/usr/local/bin/perl open (OLD, 'old.txt'); open (NEW, '>new.txt'); while (<OLD>) { chomp; next unless $_ =~ /\t/ && /0.000000/; next unless $_ !~ "F"; $_ =~ s/\t//; print NEW ("$_\n"); } close (OLD); close (NEW);

Any feedback is greatly appreciated:-)


In reply to Text Massage by GiJoe

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.