It's working fine (Perl v5.10.1):
#!/usr/bin/perl use strict; use warnings; my %frequency; while(<DATA>) { my @column = split ' ' or next; $frequency{$column[2]}++; } { local($\, $,) = ("\n", "\t"); # tab delimited output foreach (sort { $frequency{$b} <=> $frequency{$a} || $a <=> $b } k +eys %frequency) { print $_, $frequency{$_}; } } __DATA__ 0.000000e+00 105 35324 1.000000e+00 105 35324 2.000000e+00 105 33308 3.000000e+00 105 35324 4.000000e+00 105 33308 5.000000e+00 105 35324 6.000000e+00 105 33227 7.000000e+00 105 33011 8.000000e+00 105 33227 9.000000e+00 105 35606 1.000000e+01 105 33227 1.100000e+01 105 35537

To get input from a file, see [Re^2: Alphanumeric sort].

Have a nice day, j


In reply to Re^3: to count the number of occurence of a number by reisinge
in thread to count the number of occurence of a number by extrem

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.