> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, August 20, 2002 2:54 PM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; > [EMAIL PROTECTED] > Subject: RE: (Question about a script) > > > This will be fine if it is not a continously running > script. The -M > is in reference to the 'startup of the script'. So if over > time this becomes > a service, then the -M will not do what you expect. > > Been there and caught. Just a heads up.
If you want to be purist, you could also rewrite the get_diff() as: sub get_diff { local $^T = time; # in case Wags makes us a daemon :~) -M shift; } > > Wags ;) > > -----Original Message----- > From: Bob Showalter [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, August 20, 2002 11:30 > To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] > Subject: RE: (Question about a script) > > > > -----Original Message----- > > From: david [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, August 20, 2002 2:11 PM > > To: [EMAIL PROTECTED] > > Subject: Re: (Question about a script) > > > > > > the following should get you started: > > > > #!/usr/bin/perl; > > > > use Time::Local; > > > > @servers = ('server1','server2','server3'); > > @users = ('user1','user2','user3'); > > @files = ('file1','file2','file3'); > > > > foreach my $file (@files){ > > #-- if the file is older than 7 days > > if(get_diff($file) > 7){ > > #-- to each server > > foreach my $server (@servers){ > > #-- to each user > > foreach my $user (@users){ > > #-- you will replace the following > > #-- with your actual mailer. i can't help > > #-- you on that :-) > > print "HI $server: $user: $file is > older than 7 > > days\n"; > > } > > } > > } > > } > > > > sub get_diff(){ > > #-- today > > my($day,$month,$year) = (localtime)[3..5]; > > #-- file's last modified date in seconds > > my $lm = (stat(shift))[9]; > > #-- turn day/month/year into seconds > > my $sd = timelocal(undef,undef,undef,$day,$month,$year); > > #-- turn seconds into days > > return int(abs($lm-$sd) / (24*60*60)); > > } > > Perl's -M file operator can help here. It gives the age in > days of a file. > > perldoc perlop, search for "-X" > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]