title: Determining the subroutine name of a Perl code reference
body: <p>How would one determine the subroutine name of a Perl code reference?  I would also like to distinguish between named and anonymous subroutines.</p>
  
  <p>Thanks to <a href="https://stackoverflow.com/questions/5589397/printing-out-the-code-of-an-anonymous-subroutine">this question</a> I know how to print out the code, but I still don't know how to get the name.</p>
  
  <p>For example, I'd like to get 'inigo_montoya' from the following:</p>
  
  <pre><code>#!/usr/bin/env perl
  
  use strict;
  use warnings;
  
  use Data::Dumper;
  $Data::Dumper::Deparse = 1;
  
  my $sub_ref = \&amp;inigo_montoya;
  
  print Dumper $sub_ref;
  
  
  
  # === subroutines ===
  
  sub inigo_montoya {
    print &lt;&lt;end_quote;
  I will go up to the six-fingered man and say, "Hello. My name is Inigo
  Montoya. You killed my father. Prepare to die."';
  end_quote
  }
  </code></pre>