Created
July 1, 2012 06:13
-
-
Save Cside/3027087 to your computer and use it in GitHub Desktop.
show-method (Ruby: pry) on Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# Usage: $ show-method.pl Module::Name::method | |
use strict; | |
use warnings; | |
use Sub::Inspector; | |
use Class::Load qw(load_class); | |
my ($module, $method) = shift =~ /^(.+)::(.+)$/ | |
or die "Usage:\n\tshow-method.pl Module::Name::method\n"; | |
load_class($module); | |
my $code = $module->can($method) | |
or die qq|"$module" don't has method "$method"|; | |
my $ins = Sub::Inspector->new($code); | |
my $file = $ins->file; | |
my $line = $ins->line; | |
exec("vim +$line $file") if $file && $line; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment