hello this is my first post. I think third column has some special meaning which I don't know. If treat rows with each third column value, how about like this?
use strict; use warnings; my @key=("key", "start", "end"); my @data=(); my $key_pre=0; while(<DATA>) { my %hash; @hash{@key}=(split(/,/,$_))[2 .. 4]; #(key=>1, start=>23, end=> +45) if ($key_pre != $hash{key} ){ &proc_eachkey( \@data ) if $#data > 0; @data=(); } $key_pre=$hash{key}; push @data, {%hash}; #copy hash value } &proc_eachkey( \@data ) if $#data > 0; #for last key sub proc_eachkey { my ($data)= @_; my ($start_pre, $end_pre)=(0,0); foreach my $h (@$data){ if ($end_pre != $h->{start} + 1) { printf "%d,%d,%d\n", $h->{key}, ($start_pre + 1), ($h->{s +tart} -1); } printf "%d,%d,%d\n", $h->{key}, $h->{start}, $h->{end}; ($start_pre, $end_pre)=($h->{start}, $h->{end}); } } __DATA__ 1,34,1,23,45,2,2 35,45,1,56,78,1,1 46,56,1,88,101,2,2 57,68,2,13,34,4,3 69,78,2,45,56,1,3
nothing better than ikegami's one. regards.

In reply to Re^4: adding the missing sequence numbers by remiah
in thread adding the missing sequence numbers by Anonymous Monk

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.