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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |