Thank you all for your precious help once again.

I´ve made the following code that works

use strict; use warnings; my $path='D:\npodev\forms\src'; my @intervalos= ("[a-e]", "[f-h]", "[i-m]", "[n]", "[o-s]", "[t-z]"); my $esquema="RMS_MC"; my $start_flag = '<REANALYZED>'; my $stop_flag = '</REANALYZED>'; sub procura_ficheiros{ my ($path,$intervalo)=@_; opendir(DIR, $path) ||die "$!"; my @files=grep{/^$intervalo.*\.[f|m]/i} readdir(DIR); closedir (DIR); my $aux=0; foreach my $pos (@files){ $files[$aux]="\t\"".$path."\\".$files[$aux]."\""." $esquema\n"; $aux++; } return @files; } foreach my $intervalo (@intervalos){ my @ola=procura_ficheiros($path,$intervalo); my $replacement = join "", @ola; open ORIGINAL, "< teste.txt" or die "can't open original file\n"; my $original; { local $/; $original = <ORIGINAL>; } close ORIGINAL; $original =~ s/ $start_flag .*? (\s*) $stop_flag \n /$start_flag\n$replacement$1$stop_flag/gsx; open COPY, "> copy.txt" or die "can't write to copy\n"; print COPY $original; close COPY; system "hello.bat"; }

Thank you..

Nuno

In reply to Re: Search and Replace by nofernandes
in thread Search and Replace by nofernandes

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.