We help IT Professionals succeed at work.
Get Started

Perl script to parse log and delete the file

gaurav sharma
Last Modified: 2015-05-31
Below is the log file I have. I need help to create a perl script which will

1. Look for the word ERROR at string in the log and
2.  Find the first occurrence of line executing: @  before the word ERROR at and
3. Delete the file following the @ sign
4. If the file does not exist while trying to delete dont error out.

In the below log file once the ERROR at string is found ........ONLY the file at C:\Dir1\jobs\AVA\work\ora\arc\test_99.sql needs to be deleted.

connecting to Oracle with C:\oracle\instantclient/sqlplus.
executing: @C:\Dir1\jobs\AVA\work\ora\arc\test_99.sql
ERROR at line 1:
ORA-00922: missing or invalid option 

Finished execution.

connecting to Oracle with C:\oracle\instantclient/sqlplus.
executing: @C:\Dir1\jobs\AVA\work\ora\arc\test_88.sql

Finished execution.

Open in new window

Watch Question
Most Valuable Expert 2014
Top Expert 2015
This problem has been solved!
Unlock 1 Answer and 17 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE