In response to part a) of your question, you can send Tor a SIGHUP. This won't kill the process, merely cause it to reload its configuration file, and create a new circuit.

In your script you could either use `kill` (using `system()`, etc.), in which case you'd need to know the pid of the Tor process you're controlling, or `pkill`, though in the case of the latter, you'd have no way of distinguishing between different Tor processes (if you were running more than one).

`kill -SIGHUP <pid_of_tor>`

Or:

`pkill -SIGHUP tor`

This assumes you're on a Linux box. I believe OS X has the similar `-HUP` signal, and I imagine Windows does too. Check the `man` page for more signals that can be handled by the process.

With regards to part b) of your question, I don't have any Perl-specific suggestions. If you're open to other scripting languages, have a look at [Stem][1] - a fully featured Python API - or one of the other controller libraries listed on [Stem's FAQ page][2].

**Edit**

The following short script has been tested and works with the desired effect of killing an already-running Tor process:

    #!/usr/bin/perl
    use strict;
    
    system('pkill -SIGHUP tor')


  [1]: https://stem.torproject.org/
  [2]: https://stem.torproject.org/faq.html#are-there-any-other-controller-libraries