in reply to Search and replace from one list to another

I'm assuming you can process the relevant files for their contents, so the problem is essentially the substitution:

c:\@Work\Perl\monks>perl -wMstrict -le "my %hid = ( '1541' => '+12507741234', '926' => '+12505801234', '927' => '+17789701234', '970' => '+16137941234', ); ;; my ($rx_hid) = map qr{ (?<! \d) (?: $_) (?! \d) }xms, join '|', map quotemeta, reverse sort keys %hid ; print $rx_hid; ;; my $msg = join qq{\n}, 'handle_id = 1541 Sent Fri Mar 23 13:41:02 2018', 'text = Hi Partner: Called your house & you are at a mtg.', 'handle_id = 1541 Received Fri Mar 23 16:12:25 2018', 'text = I got you bud', 'handle_id = 970 Sent Fri Mar 23 16:13:56 2018', 'text = Please pickup milk.', ''; print qq{[[$msg]]}; ;; $msg =~ s{ (?i) handle_id \s* = \s* ($rx_hid) } {id = $hid{$1}}xmsg; print qq{<<$msg>>}; " (?msx-i: (?<! \d) (?: 970|927|926|1541) (?! \d) ) [[handle_id = 1541 Sent Fri Mar 23 13:41:02 2018 text = Hi Partner: Called your house & you are at a mtg. handle_id = 1541 Received Fri Mar 23 16:12:25 2018 text = I got you bud handle_id = 970 Sent Fri Mar 23 16:13:56 2018 text = Please pickup milk. ]] <<id = +12507741234 Sent Fri Mar 23 13:41:02 2018 text = Hi Partner: Called your house & you are at a mtg. id = +12507741234 Received Fri Mar 23 16:12:25 2018 text = I got you bud id = +16137941234 Sent Fri Mar 23 16:13:56 2018 text = Please pickup milk. >>
See also haukex's Building Regex Alternations Dynamically.