#!/usr/bin/perl open MY_PID, "> /tmp/do_stuff.pid" or die "can't write to /tmp/do_stuff.pid: $!"; print MY_PID $$; close MY_PID; # rest of code