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

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.