
liketheperl2009
Novice
Dec 4, 2009, 8:41 PM
Post #1 of 23
(2271 views)
|
Hi can somebody offer some assistance with this following script? #!/usr/bin/perl use warnings; use strict; my($day, $month, $year) = (localtime)[3,4,5]; $month = sprintf '%02d', $month+1; $day = sprintf '%02d', $day; my $currentdate = print $year+1900, $month, $day, ".log"; open(DATA, "<$currentdate"); while(<DATA> =~ m/MemoryException/g){ ##MemoryException reaches 5 times send email warning } close (DATA); What i would like to know is this: 1)Can i use a variable to specify a file name. Reason i'm doing this is cause i have a directories with filenames that rotate every night so the format would look like this 20091204.log For some reason though if i run it i get the following ~ readline() on closed filehandle DATA at date.pl line 14. 20091204.log1 and if i specify \n i get 20091204.log 1 where the heck does that 1 come from? And i would also like to know how if the expression is meet say 5 times to send out an email alert. Thanks,
|