No, not hash, but array. Your array elements are now references to anonymous arrays, so you need to dereference them.
foreach $element( keys %count ) { $name = $element; push @referrers, [ $element, $name, $count ]; } my @sorted_referrers = sort { $a->[2] cmp $b->[2] } @referrers; print "@$_\n" for @referrers; print "@$_\n" for @sorted_referrers;

I suggest you read up on references - perlreftut is a good place to start.

Lastly, it looks as though you're neither using strict nor enabling warnings. While they cause extra work by forcing you to use my all over the place, they will also save you from subtle bugs caused by typos, or variables that are visible or retain their value in parts of the code where you didn't intend them to. Save your own and your successor's sanity by getting into the habit of using strictures and warnings for anything longer than 5 lines at most.

Update: I realize these prints there must look somewhat confusing. I should probably give you a verbose, spelled out version:
foreach my $referrer (@referrers) { print "$@referrer\n"; }
or a really ugly version which dereferences each separate element and prints them with pipes, solely for the purpose of the demonstration of the two syntaxes to access a referenced array's members:
foreach my $referrer (@referrers) { print $referrer->[0] . "|" . $$referrer[1] . "|" . $referrer->[2] +. "\n"; }
I prefer the arrow syntax. (Outside demonstration purposes, I'd solve this as follows:
foreach my $referrer (@referrers) { print join "|", $@referrer; }

which obviously isn't much of an example.

Again, perlreftut is the doc to read. Hope this helps. :)

Makeshifts last the longest.


In reply to Re^3: Sorting CSV array by Aristotle
in thread [untitled node, ID 178427] by Samn

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.