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!

In reply to Re^3: Create separated column for my file by thanos1983
in thread How can I print all lines? by 345qwerty

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.