in reply to Sorting by values doesn't work

It isn't the cause of the particular error message you mention, but the last character in your example is wrong. - It should be a round bracket, not curvy.
foreach $k(sort {$match{$a}<=>$match{$b}} keys %match} ^ foreach $k(sort {$match{$a}<=>$match{$b}} keys %match) { }
It's good to copy-and-paste code examples so that you don't introduce other errors in the re-typing.