in reply to possible to determine the name of a sub from a sub reference?

You might make your task easier by moving it to an earlier point in the code. Rather than trying to find out the name of the subroutine that's already assigned, stick the name of it into the log at the same point in the program where the subroutine is selected.

A dispatch table built around a hash is a quick and easy way to do this in most situations. It gives you a label to match to determine which subroutine to call which can also be logged before the call is made.

use strict; use warnings; sub one { print "one\n"; } sub two { print "two\n"; } sub tres { print "never selected!\n"; } my %dispatch = ( 'one' => \&one, 'uno' => \&one, 'two' => \&two, 'dos' => \&two, 'default' => sub { print "sorry, $_[0] not found.\n"; }, ); my @do_these = qw( one two uno dos tres ); my $log; open $log, '>>', 'example.log' or die "Cannot write to log: $!\n"; foreach my $do_this ( @do_these ) { if ( exists $dispatch{ $do_this } ) { print $log $do_this . "\n"; $dispatch{ $do_this }->(); } else { print $log "default: $do_this not found\n"; $dispatch{ 'default' }->( $do_this ); } }