#!/usr/bin/perl use win32::OLE qw(in); $search="Vuser Terminated"; open(INFO, "E:\\Mibor_TimingTest\\Mibor\\output.txt"); @array=; close (INFO); foreach $line(@array){ if ($line =~ /$search/) { print "found $line"; $i=1; open(COUNT, ">>","c:\\perl\\scripts\\counter.txt")|| die "I cannot open the file"; print (COUNT "$i"); @array2=; 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 = ; eval $code; return $@; } } }