Hello, I have a log file that needs to be parsed. The logic is to find the word " Error at " (case insensitive) in the text file and once found read backwards to to find the first occurrence of string starting with word executing: (something like below) executing: @C:\parse_test\test\dir1\dir1.sql and once found delete or unlink the file at the path. In this case delete dir1.sql and not dir2.sql. The log file has the below contents
connecting to Oracle with C:\Oracle\instantclient/sqlplus. executing: @C:\parse_test\test\dir1\dir1.sql alter tablexxxxxx add xxxxxxxxL VARCHAR2(3) * ERROR at line 1: ORA-01430: column being added already exists in table ERROR at line 37: ORA-01430: column being added already exists in table Comment created. Finished execution. connecting to Oracle with C:\Oracle\instantclient/sqlplus. executing: @C:\parse_test\test\dir2\dir2.sql alter table XXXXXXXXXX rename column XXXXXX to PXXXXXXX Table altered. Comment created. Finished execution.
so far I have
#!/usr/bin/perl {local $/;$_=<>} unlink $1 or warn "$1 $!" while /executing: \@(.*)(?ms:.*?ERROR at)/g;
Running this as test.pl C:\logfile\dir\log.txt It seems to be inconsistently working. Sometimes it deletes files that got successfully executed.

In reply to Parse the text file output and delete files by Gaurav99

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.