#!usr/bin/perl -W use strict;# forces predeclaration of variables use diagnostics;#diagnostic tools #use Data::Dumper::Simple;#print out contents of variables use porter; # load the porter stemmer module my %hashA = ( 'accord newton second' => 80, 'acceler smaller greater' => 78, 'addit law motion' => 56, 'meant bodi act forc'=> 55, ); foreach my $key(keys %hashA){ #print "$key $hashA{$key}\n"; } my %hashB = (2 => 'addit law motion', 3 => 'accord newton second', 4 => 'meant bodi act forc', 5 => 'acceler smaller greater', ); foreach my $key(keys %hashB){ #print "$key $hashB{$key}\n"; } my @sorted_scores = keys %hashA;#keys from hash A foreach (@sorted_scores){# this gives sorted text #print "$_\n"; } my @sorted_words = map { $hashA{$_} } @sorted_scores;#sorted text foreach (@sorted_words){ #print "$_\n";# this gives the scores sorted out } my %hashC = (2 => "In addition to ", 3 => "According to Newton", 4 => "It also meant that whenever ", 5 => "The acceleration is", ); my (@line_Numbers); my %reversehashB = reverse %hashB; @line_Numbers = map { $reversehashB {$_} }@sorted_scores; foreach (@line_Numbers){ #print "$_\n"; } foreach (@line_Numbers){ print ($_,' ', $hashC{$_}, "\n"); }