One thing that leaps out at me is that you are sorting the keys of %mapper each time you read a record from input_file. Not sure how big a key is, but it might be worth sorting the keys just once before you read input_file, since you don't appear to alter the hash, this should be safe (although I don't know how big a key is). e.g.
my @map_keys = sort keys %mapper;
...
foreach $key (@map_keys) {
...