http://qs321.pair.com?node_id=910872


in reply to Re: Perl sorting unique values
in thread Perl sorting unique values

my %hash; open (FILE,"abc.txt"); while (<FILE>) { chomp; my ($key,$val) = split '\|'; print $hash{$val}; }
This is a bit of code which i have written,i did not applied sort on it till now.But,its not working.

Replies are listed 'Best First'.
Re^3: Perl sorting unique values
by wind (Priest) on Jun 22, 2011 at 10:14 UTC

    Almost there:

    use strict; use warnings; my %hash; open my $fh, '<', 'abc.txt' or die $!; while (<$fh>) { chomp; my ($key, $val) = split '\|'; $hash{$val}++; } print "$_\n" for sort keys %hash;