Yes, you can use a regex to get the words from file1 that you're going to search for and insert into file2. There are many different ways it could be written, but here's one example:
my $str = q|{RP}makaravilYakkin Sabarimala ayyappanu cArZwwAnulYlYa wi +ruviwAMkUrZ rAjAvAyirunna SrI ciwwirawirunnAlYZ bAlarAmavarZmma natak +k vacca 420 kilogrAM wUkkamulYlYa wafkayafki{/RP}{MCL} sUkRikkunnaw +I kRewrawwilAN.{/MCL}|; while ($str =~ m[ {(\w+)} # a word within {}, capture it \W* # maybe non-word chars (\w+) # first word after tag, capture it [^{]+ # anything but a {, up to... \W # a non-word character (\w+) # last word before tag, capture it \W* # maybe non-word chars {/\1} # ending tag matching captured one above ]xg){ print "$1 $2 $3\n"; # print captured values }
Aaron B.
Available for small or large Perl jobs; see my home node.
In reply to Re^7: merging a file with a value present in another file
by aaron_baugher
in thread merging a file with a value present in another file
by lakssreedhar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |