Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cside/universal-source_location_for
Get source filename and line number of a subroutine
https://github.com/cside/universal-source_location_for
Last synced: 2 days ago
JSON representation
Get source filename and line number of a subroutine
- Host: GitHub
- URL: https://github.com/cside/universal-source_location_for
- Owner: Cside
- Created: 2012-03-13T05:31:00.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-04-27T04:40:38.000Z (over 10 years ago)
- Last Synced: 2024-10-28T16:34:04.507Z (about 2 months ago)
- Language: Perl
- Homepage:
- Size: 159 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.pod
- Changelog: Changes
Awesome Lists containing this project
README
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.
It's useful for debug.
=head2 Functions
=head3 C<< Module->source_location_for('method') >>
Reuturn source filename and line number of the subroutine.
=head1 AUTHOR
Fuji, Goro (gfx) Egfuji(at)cpan.orgE
Hiroki Honda Ecside.story gmail.comE
=head1 LICENSE AND COPYRIGHT
Copyright (c) 2012, Hiroki Honda.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.=cut