begood321 has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; sub file_handler { my ($abs_filename) = @_; if ((($current_mth == 1) && ($last_day_current_mth == 31)) threeYrExpiration($abs_filename); } # End of sub file_handler sub threeYrExpiration ($) { my $abs_filename = $_[0]; my $unlinkStatus = unlink("$abs_filename"); if ($unlinkStatus == 1) { $unlinkCountTotal++; $abs_filename =~ s#.*WORKAREA\/[^\/]*##; push (@deleted_files, $abs_filename); $task->AddFile("$abs_filename", "Deleted by content expiration + report"); $logger->info("File to be deleted added to job: $abs_filename" +); } else { $logger->info("File to be deleted \"$abs_filename\" failed. Re +ceived $unlinkStatus instead of 1."); $task->CallBack(1, "Error Deleting expired file"); } }
gives me this error message / faulty output:
Mon Nov 29 10:21:34 2010 : INFO : expiration_report.ipl : ************ +******************************************************************* Mon Nov 29 10:21:34 2010 : INFO : expiration_report.ipl : File to be d +eleted added to job: /committees/comm_wkgrps/inactive/cold_snap_tf/eu +ropepass.pdf Mon Nov 29 10:21:34 2010 : INFO : expiration_report.ipl : File to be d +eleted "/iwmnt/default/main/internet/WORKAREA/home/committees/comm_wk +grps/inactive/cold_snap_tf/europepass.pdf" failed. Received 0 instead + of 1.
I'm trying to unlink (delete) a file by calling sub threeYrExpiration from within sub file_handler
If I move code from threeYrExpiration to file_hander it works (return 1 for unlink status). I need this to work as I have other sub which I wanted to include in file_handler sub to be called also.p>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Delete file from sub call within another sub
by kennethk (Abbot) on Nov 29, 2010 at 16:58 UTC | |
by begood321 (Novice) on Nov 29, 2010 at 17:21 UTC | |
by kennethk (Abbot) on Nov 29, 2010 at 17:27 UTC | |
by begood321 (Novice) on Nov 29, 2010 at 18:48 UTC | |
by kennethk (Abbot) on Nov 29, 2010 at 19:44 UTC | |
|
Re: Delete file from sub call within another sub
by locked_user sundialsvc4 (Abbot) on Nov 29, 2010 at 17:53 UTC | |
by begood321 (Novice) on Nov 29, 2010 at 19:45 UTC |