Skip to content

Instantly share code, notes, and snippets.

@Cside
Created July 1, 2012 06:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cside/3027087 to your computer and use it in GitHub Desktop.
Save Cside/3027087 to your computer and use it in GitHub Desktop.
show-method (Ruby: pry) on Perl
#!/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