I don't understand what you're doing. If you execute the Perl statement
    my $out = qx/grep -A 3 -B 3 xxx  file-B >> file-A/;
then  $out will be empty because output is re-directed to file-A.

c:\@Work\Perl\monks\jjmoka>dir Volume in drive C is Acer Volume Serial Number is 9480-355B Directory of c:\@Work\Perl\monks\jjmoka 01/20/2020 03:28 PM <DIR> . 01/20/2020 03:28 PM <DIR> .. 01/20/2020 03:22 PM 95 file-B 1 File(s) 95 bytes 2 Dir(s) 76,795,633,664 bytes free c:\@Work\Perl\monks\jjmoka>type file-B one two three four five six seven eight nine ten eleven twelve thirteen fourteen c:\@Work\Perl\monks\jjmoka>perl -wMstrict -MData::Dump -le "my $out = qx/grep -A 2 -B 2 four file-B >> file-A/; dd $out; " "" c:\@Work\Perl\monks\jjmoka>type file-A two three four five six -- twelve thirteen fourteen
This is under Win7, Perl 5.8.9.


Give a man a fish:  <%-{-{-{-<


In reply to Re: extract the tail from a string (with new lines) containing a substring by AnomalousMonk
in thread extract the tail from a string (with new lines) containing a substring by jjmoka

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.