Try something like this:

c:\@Work\Perl\monks\lewars>perl -wMstrict -le "use Data::Dump qw(dd); ;; my $xlate_file = 'lookup.dat'; open my $fh_xlate, '<', $xlate_file or die qq{opening '$xlate_file': +$!}; ;; my %xlate = map { m{ \A (\S+) \s+ (.+?) \s+ \z }xms } <$fh_xlate> ; dd \%xlate; close $fh_xlate or die qq{closing '$xlate_file': $!}; ;; my ($rx_ref) = map qr{ \b (?: $_) \b }xms, join ' | ', map quotemeta, reverse sort keys %xlate ; print $rx_ref; ;; my $master_file = 'master.dat'; open my $fh_master, '<', $master_file or die qq{opening '$master_file +': $!}; ;; my $master = do { local $/; <$fh_master> }; close $fh_master or die qq{closing '$master_file': $!}; ;; $master =~ s{ ($rx_ref) }{$xlate{$1}}xmsg; print qq{[[$master]]}; " { Ref00004 => "https://dealerportal4.xx.com/siteminderagent/forms/xx.f +cc;ACS=0", Ref00005 => "https://sso.xx.com/siteminderagent/forms/xx.fcc;ACS=0;R +EL=0", Ref00006 => "https://secure3.xx.com/siteminderagent/forms/xx.fcc;ACS +=0;REL=0", Ref00007 => "https:///siteminderagent/cert/smgetcred.scc?cert", Ref00008 => "https://secure4.xx.com/siteminderagent/forms/xx.fcc;ACS +=0;REL=0", Ref00009 => "https://vbos-uat.xx.com/siteminderagent/forms/xx.fcc;AC +S=0;REL=0", } (?msx-i: \b (?: Ref00009 | Ref00008 | Ref00007 | Ref00006 | Ref00005 | + Ref00004) \b ) [[<Property Name="CA.SM::AuthScheme.IsUsedbyAdmin"> <BooleanValue>false</BooleanValue> </Property> <Property Name="CA.SM::AuthScheme.Desc"> <StringValue>TCP portal auth scheme</StringValue> </Property> <Property Name="CA.SM::AuthScheme.Level"> <NumberValue>5</NumberValue> </Property> <Property Name="CA.SM::AuthScheme.IsTemplate"> <BooleanValue>false</BooleanValue> </Property> <Property Name="CA.SM::AuthScheme.Param"> <LinkValue><XREF>https://sso.xx.com/siteminderagent/forms/xx.fcc;A +CS=0;REL=0</XREF></LinkValue> </Property> <Property Name="CA.SM::AuthScheme.Library"> ]]
Notes:

Update: For a good discussion of the technique used above to build the  $rx_ref regex matching object, see Building Regex Alternations Dynamically by haukex.


Give a man a fish:  <%-{-{-{-<


In reply to Re: Replace string in one file using input from another file by AnomalousMonk
in thread Replace string in one file using input from another file by lewars

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.