So, I am basically here:
open IN2, $first_tmp; while(<IN2>) { if($_=~/^(chr.*?)REC:(.*)/) { $respective_chrom=$1; $all_entries=$2; @split_entries=(); @split_entries = split(/\#/, $all_entries); @split_sep_entries=(); %collapsed_loci_HoA=(); print ">".$respective_chrom."\n"; foreach $sep_entry(@split_entries) { @split_sep_entries = split(/\t/, $sep_entry); $locus_to_use = $split_sep_entries[1]; $rest_entry=$split_sep_entries[0]."\t".$split_sep_entries[ +2]."\t". $split_sep_entries[3]."\t".$split_sep_entries[ +4]."\t". $split_sep_entries[5]."\t".$split_sep_entries[ +6]."\t". $split_sep_entries[7]; push @{ $collapsed_loci_HoA{$locus_to_use} }, $rest_entry; } @array_of_loci = keys %collapsed_loci_HoA; for $b(sort { $b <=> $a } @array_of_loci) { $count_arr++; } print "//\n"; } } close IN2;

and basically I am now getting my numbers sorted, as I posted above...
What I cannot do is exactly this binning you propose, my thoughts are to slice each time one element of the array and, if it is within the range, push it to the sub-array of the element that created it, but I really can't see how to do that.
I am new to Perl and I am literally stuck..

In reply to Re^2: Stuck with manipulating an array by Anonymous Monk
in thread Stuck with manipulating an array 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.