Using key to match against source.txt file to add xml tags to names in Perl
Using a list of names (over 4000 of them) painstakingly gleaned from the source file years ago for a database file, I want to match the names against the source file so that they can be updated with the tags <forename></forename> in the original source file.
I placed the list of names in @forenames (only posted a few of them here).
Perl script is:
sysopen(DATA, "+>asource.txt", O_RDWR);
@forenames=(" Alani fratris", "uxori brichtmeri","uxori brihtmari","uxori hugonis","uxori ricardi ","uxori roberti","uxori waldini","uxori willelmi","uxoris alani","uxoris baderun","uxoris gaufridi","uxoris grentonis","uxoris hamonis","uxoris herberti","uxoris hugonis","uxoris oini","uxoris rogeri","uxoris stephani","uxoris thome","uxoris walcini","uxoris willelmi","v","vaganus"
@first = (@forenames);
foreach $key (@first)
close(DATA) || die "Couldn't close file properly";
I am able to get the name bracketed by the tags to appear on the console screen but don't know how to apply the output to the source file. Perhaps I need to do a match on the words then some kind of edit to surround the matching words with the xml tags? I'm a rank novice doing this as a labour of love for a friend.
Thank you for any help.