use warnings; use strict; my %hash_val; while (<>) { while (/\b([[:alpha:]]{3}).+?\(.+?(\d+?)\)/gs) { $hash_val{$1} = $2; } } print $_,'=',$hash_val{$_},$/ foreach keys %hash_val;