Help! A file of a list with 4 fields is used to match for another file. 1st field used as "name" for "name.xml" file to be seached. 2nd will eventually be used for the final text search. 3rd and 4th fields used to match location that precede the chunk that contains final text. The problem is 3rd and 4th sometimes will be with the text desire as one line, other times not. So, in that case I will need simply print the next line. the following code was not able to give a $`, anyone see why?

The normal part of name.xml look like this:

blah blah more lines of blah asdkb ------------------------ 0030 and 0022 are field 2 and 3

while (<>){ my @arr=split('#'); chomp(@arr); my $n=0; system("cat ff/$arr[0].xml >temp"); open FILE, "temp" or die $!; while(<FILE>){ if($n==1){$n=0;print "matched previously but now second line $_";} else { if (/$arr[2].*$\n/g) { if (($`=="") && $n==0)) { print "matched but text on next line";$n=1; } else { print "matched: $` \n";};};print "\r\n "; }; }; }; system("rm temp"); };

In reply to can NOT get content after matched place by ygu95at

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.