http://www.perlmonks.org?node_id=6638

   1: $caller = "My::Class::Path::myfunc";
   2: 
   3: # Fastest method
   4: # regex-with-prematch
   5: my ($func) = $caller =~ /::([^:]*)$/;
   6: my $class = $`; # aka. $PREMATCH
   7: 
   8: # Second place; only .09sec in 100,000 iterations slower
   9: # split-pop-join
  10: my (@objpath) = split(/::/, $caller);
  11: my ($func)  = pop @objpath;
  12: my ($class) = join('::', @objpath);
  13: 
  14: # Third place; 25% slower
  15: # globalrx-pop-join
  16: my (@objpath) = $caller =~ /([^:]+)/g;
  17: my ($func)  = pop @objpath;
  18: my ($class) = join('::', @objpath);