in reply to Pattern transfer
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) ?
|
|---|