in reply to Re: Create separated column for my file
in thread How can I print all lines?

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^2: Create separated column for my file

Replies are listed 'Best First'.
Re^3: Create separated column for my file
by thanos1983 (Parson) on Aug 10, 2017 at 13:38 UTC

    Hello again 345qwerty,

    What this is reply is suppose to be? It is easy to see that your code is not written by you, you copy pasted some parts and you hope that this work.

    Your code is not compiling:

    $ perl test.pl Use of uninitialized value $file in scalar chomp at test.pl line 10.

    After fixing your error and modifying your code to be able to compile, I get the following:

    #!/usr/bin/perl use strict; use warnings; my $path2file = 'Q.txt'; open my $fh, '<', $path2file; chomp(my @column = <$fh>); close $fh; my $number=0; while($number <= $#column) { #go through the array from 0 to the last +element my $j; my $count=0; foreach ($j=$number; $j < $#column; $j++) { #select the numbers fr +om the beginning of the line in the current and next element my $d=($column[$j]=~/(\d+)/)[0] - ($column[$j+1]=~/(\d+)/)[0]; #di +fference last if abs($d)!= 1; #if differ more than 1 - leave $count+=$d; #accumulate the difference } if(abs($count)>=7) { chomp($column[$_]); $column[$_]=$column[$_]. "\tIN\n" for $number..$j; #IN if >8 $number=$j+1; } if (abs($count)<8) { chomp($column[$number]); $column[$number] = $column[$number]."\tOUT\n"; #OUT if < 8 $number++; } } print for @column; __END__ $ perl test.pl Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. Use of uninitialized value in subtraction (-) at test.pl line 16. 5 Q CAA OUT OUT 16 Q CAG OUT OUT 21 Q CAA OUT OUT 74 Q CAA OUT OUT 80 Q CAG OUT OUT 82 Q CAG OUT OUT 84 Q CAG OUT OUT 85 Q CAG OUT OUT 89 Q CAG OUT OUT 90 Q CAG OUT OUT 91 Q CAG OUT OUT 92 Q CAG OUT OUT 93 Q CAA OUT OUT 94 Q CAG OUT OUT 95 Q CAG OUT OUT 96 Q CAG OUT OUT 98 Q CAG OUT OUT 99 Q CAG OUT OUT 100 Q CAG OUT

    Make your code executable, make your code produce the output file and then I could spend some time to assist you. I am sorry at this point I stop. When someone spends his time for free trying to assist you and you simply copy paste a reply to a question into a non compiling code, sorry but there is not point of working on this anymore. Maybe another monk will be more patient to assist you.

    Update your code and your attitude and then we can talk about it again, BR.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
Re^3: Create separated column for my file
by huck (Prior) on Aug 10, 2017 at 13:18 UTC

    Well it is plainly obvious that you are leaving the \n on the IN lines, isnt it? Why dont you look at where you append IN to see what may be wrong?

    Just what do you expect $_ to have in it when you say chomp($column[$_]);?