http://www.perlmonks.org?node_id=1019358


in reply to Re^2: Kill a perl script execution in windows
in thread Kill a perl script execution in windows

you don't need the PID. The first script waits for a signal to terminate as:
use Win32::Event; use 5.010; $event = Win32::Event->new(1,0,"myevent"); while ($event->wait(0)==0) { say $i; print $i++; } say "exiting";
or just $event->wait(), depends on the situation.Then the second one can signal it to abort :
use Win32::Event; use 5.010; $event = Win32::Event->new(1,0,"myevent"); say $^E; $event->set;