in reply to getting a subroutine's name

I have used these simple subs many times to great effect. I put them in a "standard utility module" that I use in many programs. I recommend just setting these short subs to return a string, don't use values in main calling program to separate things out. Perhaps these things should/could be called iwascalledby() hewascalledby(); or whatever suits your fancy.
#!usr/bin/perl -w use strict; sub whoami { (caller(1))[3] }; sub whowasi { (caller(2))[3] }; some_sub(); sub some_sub { print "Now inside some_sub\n"; print " called_by ". whoami.".\n"; another_sub(); } sub another_sub { print "Now inside another_sub\n"; print " called by ". whoami(). " \n"; print " previous sub ". whowasi(). " \n"; } __END__ Prints: Now inside some_sub called_by main::some_sub. Now inside another_sub called by main::another_sub previous sub main::some_sub
caller() has more params and they can be useful, eg. line number etc. But basically if one of my library routines gets bogus input, then I usually just need to know the name of the caller and the name of previous caller to figure out where bogus input came from.