Grabbing a huge bucket-full of guesses, and using inline files for this test case.

#!/usr/bin/perl # http://perlmonks.org/?node_id=1207825 use strict; use warnings; open my $file1, '<', \<<END; # replace with your real open 10000000 10000000 10000000 10000000 10000000 00000011 00000011 00000011 00000011 00000011 10000001 10000001 10000001 10000001 10000001 11000000 11000000 11000000 11000000 11000000 01100000 01100000 01100000 01100000 01100000 END open my $file2, '<', \<<END; # replace with your real open CHAIN_TEST = pattern = 0; apply "grp1_load" 0 = chain "chain1" = "010"; end; force "PI" "XX0XXXXXX" 1; measure "PO" "XX" 2; apply "grp1_unload" 3 = chain "chain1" = "010"; end; pattern = 1; apply "grp1_load" 0 = chain "chain1" = "101"; end; force "PI" "XX0XXXXXX" 1; measure "PO" "XX" 2; apply "grp1_unload" 3 = chain "chain1" = "101"; end; end; SCAN_TEST = pattern = 0; apply "grp1_load" 0 = chain "chain1" = "010"; end; force "PI" "100000000" 1; measure "PO" "10" 2; pulse "/CK" 3; apply "grp1_unload" 4 = chain "chain1" = "010"; end; pattern = 1; apply "grp1_load" 0 = chain "chain1" = "110"; end; force "PI" "110000101" 1; measure "PO" "11" 2; pulse "/CK" 3; apply "grp1_unload" 4 = chain "chain1" = "100"; end; pattern = 2; apply "grp1_load" 0 = chain "chain1" = "001"; end; force "PI" "010000110" 1; measure "PO" "10" 2; pulse "/CK" 3; apply "grp1_unload" 4 = chain "chain1" = "010"; end; END my $contents2 = do { local $/; <$file2> }; while( <$file1> ) { my @replacements = split; print $contents2 =~ s/"PI" "\K\w+/ shift @replacements /ger; }

Does the output match your desired output (which you didn't show us) ?


In reply to Re: Pattern transfer by tybalt89
in thread Pattern transfer by jumdesumit

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.