package UNIVERSAL::source_location_for;
use 5.008_001;
use strict;
use warnings;
our $VERSION = '0.01';
use B ();
sub UNIVERSAL::source_location_for {
my($self, $method) = @_;
my $entity = $self->can($method) or return();
my $gv = B::svref_2object($entity)->GV;
return($gv->FILE, $gv->LINE);
}
1;
__END__
=head1 NAME
UNIVERSAL::source_location_for - Get source filename and line number of a subroutine
=head1 SYNOPSIS
use UNIVERSAL::source_location_for;
use File::Spec;
my ($source_filename, $line)
= File::Spec->source_location_for('canonpath');
=head1 DESCRIPTION
This module supplys a universal function "source_location_for", a perl implementation of the method Method#source_location of Ruby.