Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created August 3, 2016 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/23a9c85af59e775c2e020b296e5114c0 to your computer and use it in GitHub Desktop.
Save zoffixznet/23a9c85af59e775c2e020b296e5114c0 to your computer and use it in GitHub Desktop.
sub where (&c) {
my $wanted = &c.line;
my $line-num = 0;
my $file;
my $offset;
for $*EXECUTABLE.parent.parent.parent.child(&c.file).IO.lines -> $line {
$line-num++;
return "$file: {$line-num-$offset}" if $line-num == $wanted;
if $line ~~ /^ '#line 1 ' $<file>=\S+/ {
$file = $<file>;
$offset = $line-num+1;
}
};
}
say "$_.name(): {where $_}" for Int.^methods;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment