Portree has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use win32::ole; use Date::Calc; use Mime::Lite; my @modify; my $modify_seconds; my $sleep_count = 0; my $final_time; my $a_final_denis = '//10./Automated Reports/Final_Denis_Test.pl'; my $backup_report = '//163./planning/Logistics/Programs/Chicago WIP Qu +ery Tools/Final_Denis_Test.pl'; &checkfile ($a_final_denis); sub checkfile { my $file = shift(@_); my $flag = 1; my $sleep_count = 0; while ($flag){ if (-e $file) { @modify = stat ($file); $modify_seconds = $modify[8]; print "$file\n"; if (&checktime ($modify_seconds, $file)) { $flag = 0; } else { $sleep_count++; if ($sleep_count > 3) {&late_file} sleep(3); } } else { print "File not found\n"; goto F_End; } } } sub checktime { my $modify_seconds = shift(@_); my $file = shift(@_); my $local_time = localtime($modify_seconds); my $current_tm = time(); $final_time = $current_tm - $modify_seconds; print "$final_time\n"; if ($final_time >= 80000) { return 0; }else { goto Q_End; } } sub late_file { open $backup_report; print "File Is Late In Updating"; exit 1; } ########################################### F_End: open $backup_report; my $msg_end = MIME::Lite->new( From =>'rzcj60@freescale.com', #who is sending the email To =>'rzcj60@freescale.com', # who is receiving the email Subject =>'Final Denis Report Innactive', # subject of the ema +il Type =>'multipart/mixed' #what type of email (it is like t +his since it is text and attachment) ); $msg_end->attach(Type =>'TEXT/Plain', #what is being atta +ched Data =>"Computer running Final_Denis automated re +port is not active" #The body of the email ); MIME::Lite->send('smtp', "freescale.net", Timeout=>60); #smtp r +outing information for email $msg_end->send; # send function exit; Q_End: print "File Updated"; exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Backticks and Sub Programs
by ikegami (Patriarch) on Sep 08, 2005 at 20:08 UTC | |
|
Re: Backticks and Sub Programs
by 5mi11er (Deacon) on Sep 08, 2005 at 19:28 UTC | |
|
Re: Backticks and Sub Programs
by ambrus (Abbot) on Sep 09, 2005 at 09:52 UTC |