Hello wonderful Perlmonks! I created a large number of files with the data layout shown below. I foolishly didn't anticipate the problem of having a newline between each line of text.

0 26 2 2699645 1 3 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 21 7 2699676 3 1 1 1 3 1 3 1 1 3 1 1 1 1 3 1 1 3 1 1 3 1 1 1 1 1 1 1 0 14 14 2699968 1 1 3 3 1 1 1 3 3 1 3 1 1 3 1 3 3 1 1 3 1 3 3 3 1 1 3 +3 0 13 15 2700027 1 1 3 3 1 1 1 3 3 1 3 1 1 3 1 3 3 1 1 3 1 3 3 3 3 1 3 +3 0 26 2 2700157 1 3 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 17 11 2700202 3 3 1 1 3 3 3 1 1 3 3 1 1 1 3 1 3 3 1 1 3 1 1 1 1 1 1 +1 0 18 10 2700302 3 1 1 1 3 1 3 3 1 3 3 1 1 1 3 1 3 3 1 1 3 1 1 1 1 1 1 +1 0 15 13 2700608 1 3 3 3 1 3 1 1 3 1 1 3 1 3 1 3 1 1 1 3 1 1 1 3 1 3 3 +3 0 15 13 2700613 1 1 3 3 1 3 1 1 3 1 1 3 1 3 3 3 1 1 1 3 1 1 1 3 1 3 3 +3

The problem this yields is in my next set of files. The blank lines return values of 0 each time they are encountered

2699645 2 0 2699676 7 0 2699968 14

Is there a way to program out these new lines between strings , in addition to the split command for single spaces? Below is my relevant code for the split command.

while($count < 155){ my $output_file = "$output_dir"."compute_minor_alleles_28_males.". +"$count".".txt"; open(OUT, ">$output_file"); print OUT "position\tminor allele frequency\n"; my $input_file = "$input_dir"."temp_file_". "$count."."txt"; open (CG, "<$input_file") or die "Cannot open $input_file:$!\n"; while (my $cg = <CG>){ if ($cg =~ /NA/){ next; } chomp($cg); #get rid of newline character @info = split(" ", $cg);

In reply to Getting Rid of Newlines Between Strings by ccelt09

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.