in reply to Introspection of labels possible?

You might consider B. Perhaps something like:

#!/usr/local/bin/perl use strict; use warnings; use B; HERE: B::walkoptree(B::main_root(), "print_label"); THERE: exit(0); sub B::OP::print_label { my $op = shift; if(ref($op) eq 'B::COP') { my $label = $op->label; if(defined($label)) { my $file = $op->file; my $line = $op->line; print "$label: $file: $line\n"; } } }

Which produces

HERE: ./test.pl: 6 THERE: ./test.pl: 8

update: The label, line and file information is stored in the Code tree (a.k.a. OP tree) - not in any stash or pad.

Replies are listed 'Best First'.
Re^2: Introspection of labels possible? (THX!)
by LanX (Saint) on Aug 30, 2009 at 22:20 UTC
    Wow, nice!!!

    Escpecially thank you for showing me new ways for how to analyze the op-tree! 8)

    Cheers Rolf