##########################prints unique and sorted salary use strict; use warnings; my %hash; open my $fh, '<', 'abc.txt' or die $!; while (<$fh>) { chomp; my ($key, $val , $val1) = split '\|'; $hash{$val1}++; } print "$_\n" for sort keys %hash; ----abc.txt------ P|PERL|50000 Paa|JAVA|20000 Poo|VB|10000 AB|SAN|20000 ABCD|CSS|500 PQRS|HTML|200 --The output is-- 10000 200 20000 500 50000