Respectable monks I have no idea how to start on this project so I will start off with a question,if you have a file
file1:home/gonzales/something.c11111entry/kapoeira/anotherthing.c11111111111111111vikings/georgebush/house.c1111111111
and another file file2:22222222222222222222222222222222
we have in file 1 as many "1" as there are "2" in file 2 and I would like to get an output of output:home/gonzales/something.c22222entry/kapoeira/anotherthing.c22222222222222222vikings/georgebush/house.c2222222222
So my question is,is there a way to tell my program to look in file 1 find out how many "1" are between the ".c" and the "entry",how many are between the ".c" and "vikings" a.s.o and take the values from file 2 and replace the ones from file 1.I am really new to perl programming so I have no idea on how to do this...Thank you in advance :D
use warnings 'all'; use strict; use autodie; open my $input, '<', 'file1.txt'; open my $input2, '<', 'file2.txt'; open my $out, '>', 'output.txt'; while ( my $sentence = <$input> ) { my $substring = '\.c.*?entry'; $sentence =~ s{$substring}{$file2}; print $out , $sentence; }
I was thinking of using something like quotemeta but I dont know how to use it in my purpose
In reply to work with files by no0bieMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |