Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Copy data from one file and add it to another

by poj (Abbot)
on Jan 24, 2018 at 11:06 UTC ( [id://1207811]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Copy data from one file and add it to another
in thread Copy data from one file and add it to another

Put a unique marker in the file eg <PATTERN> where you want the substitution.

#!/usr/bin/perl use strict; use warnings; my $infile1 = 'file1.txt'; my $infile2 = 'file2.txt'; my $outfile = 'result.txt'; #open IN,'<',$infile1 or die "$infile1 : $!"; #my @file1 = <IN>; #chomp(@file1); #close IN; my @file1 = qw(10000000 00000011 10000001 11000000 01100000 ); #open IN,'<',$infile2 or die "$infile2 : $!"; #my @file2 = <IN>; #close IN; my @file2 = <DATA>; open OUT,'>',$outfile or die "$outfile : $!"; for my $pattern (@file1){ print "Test pattern is $pattern\n"; for (@file2){ my $line = $_; # copy to preserve @file2 $line =~ s/<PATTERN>/$pattern/; print OUT $line; } } close OUT; __DATA__ SCAN_TEST = pattern = 0; apply "grp1_load" 0 = chain "chain1" = "010"; end; force "PI" "<PATTERN>" 1; measure "PO" "10" 2; pulse "/CK" 3; apply "grp1_unload" 4 = chain "chain1" = "010"; end;
poj

Replies are listed 'Best First'.
Re^4: Copy data from one file and add it to another
by jumdesumit (Novice) on Feb 01, 2018 at 10:31 UTC
    Thank you so much for your help.It's a big favor to me.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1207811]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found