I have a file-A containing some logging info.
Suppose 202 lines:
<.... line 200 ....>
<.... line 201 ....>
<.... line 202 ....>
These lines are the output of a periodical(ex. every 20min) grep (of a pattern xxx) on a certain live file-B
If I just do every 20min something like
grep -A 3 -B 3 xxx file-B >> file-A
I could fill file-A with duplicates if following greps contain same lines (or parts) of previous greps.
Every grep output is stored in a string
$out = qx/grep ... / #note that $out contains new lines
while the last line of file-A is obtained for example like:
$last = qx/tail -1 $fileA/
I'd need then to keep of $out only the <NEW> part (if any)
I thought that
if (($last =~ /\S/) && ($out =~/$last(.*)/)) {
$out = $1
}
should have done the trick, but it doesn't.
Any help to fix my wrong logic is welcome.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.