in reply to Re: Parse the text file output and delete files
in thread Parse the text file output and delete files

I am very new to perl.Will really appreciate if I have the script for the logic above.
  • Comment on Re^2: Parse the text file output and delete files

Replies are listed 'Best First'.
Re^3: Parse the text file output and delete files
by GotToBTru (Prior) on Jul 20, 2015 at 17:28 UTC

    I would explore the tutorials you can find here. Or google "perl basic file operations". Make some effort - you'll learn more that way!

    Dum Spiro Spero
Re^3: Parse the text file output and delete files
by Laurent_R (Canon) on Jul 21, 2015 at 14:56 UTC
    Hi,

    the general basic idea might perhaps be something like this:

    my $last_sql_file; while (my $line = <$LOG>) { chomp $line; $last_sql_file = $1 if $line =~ /^executing: \@(.+)/; if ($line =~ /^ERROR at/) { unlink $last_sql_file if -f $last_sql_file; # don't try to del +ete this file if it was already deleted on a previous error } }
    That's the basic algorithm, please fell free to ask if you don't understand it. I leave it to you to find out in the documentation how to open the log file if you don't know how (clue: take a look at open).