in reply to how can a subroutine find out the name of it's caller?

The caller function returns all sorts of useful stuff, and you can use it to trace all the way back up the function stack. To go back one stack frame, you can use:

sub LOG { my $msg = shift; my @cl = caller(1); print "sub ", $cl[3], " says: ", $msg; }