$newline =~ s/(\b$currword(?:ed|ing|al)?\b)/\$hashme\{$1\}/ig for @wordlist; $newline =~ s/\$hashme\{(.+?)\}/\\footnote\{$1 $hash{lc($1)}{explanation}\}/g