http://qs321.pair.com?node_id=758761

grashoper has asked for the wisdom of the Perl Monks concerning the following question:

Probably my fault cause I must be doing something dumb can't seem to find it. I want to count the number of times a file is restarted, this is to do some basic logging on attempts to automate a process, problem is only one value is being recorded in my file counter.txt, I also want errors to be logged if they occur
#!/usr/bin/perl use win32::OLE qw(in); $search="Vuser Terminated"; open(INFO, "E:\\Mibor_TimingTest\\Mibor\\output.txt"); @array=<INFO>; close (INFO); foreach $line(@array){ if ($line =~ /$search/) { print "found $line"; $i=1; open(COUNT, ">>","c:\\perl\\scripts\\counter.txt")|| die "I cannot ope +n the file"; print (COUNT "$i"); @array2=<COUNT>; foreach $line(@array2){ if ($line) { print (COUNT "$i++"); close(COUNT); } else { print "$line \n"; } } run_code; my $error = run_code('c:\\perl\\scripts\\killp.pl'); print "Run code failed, err msg:\n$error" if $error; # # add error handling code here for if vugen fails to die.. # # # sub run_code { $path="c:\\perl\\scripts"; my $path = shift; open(CODE, $path) || return "Oops: $path $!\n"; local $/; my $code = <CODE>; eval $code; return $@; } } }