Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Perl sorting unique values

by pr09 (Novice)
on Jun 22, 2011 at 09:21 UTC ( [id://910872]=note: print w/replies, xml ) Need Help??


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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://910872]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2025-06-15 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.