# -|print_topic|--------------------------------------------------------------- # Pre : t_topic # Post: # ----------------------------------------------------------------------------- sub print_topic ($) { my $t_topic = shift; open( INFILE, "$conf_file" ) or die "$!"; while () { chomp; my (%hash); next if 0 == length($_); # Solves "Use of uninitialized value in .......... " next if ( $_ !~ /^$t_topic/ ); # Only look at lines begin with the t_topic my ($topic, $desc, $url, $hits) = split "," ; if ($topic) { ${hash}{$url}{topic} = $topic if ($topic); ${hash}{$url}{desc} = $desc if ($desc); ${hash}{$url}{url} = $url if ($url); ${hash}{$url}{hits} = $hits if ($hits); } #print "Sort Numeric using <=> with supersort\n"; #print Dumper %hash , "\n"; foreach my $sorted_url ( reverse sort { $hash{$a}->{'hits'} <=> $hash{$b}->{'hits'} } keys %hash){ print $sorted_url, " has got ", ${hash}{$sorted_url}{hits}, "\n"; } } close INFILE; }