Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Separating different lexicals with B::Xref

by LanX (Saint)
on May 01, 2015 at 16:49 UTC ( [id://1125374]=perlquestion: print w/replies, xml ) Need Help??

LanX has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I thinks this question was asked before but maybe a new view might help:

In the following code two different my $a are defined in separate scopes, but the output of B::Xref doesn't help separating them.

I.e. the last use of $a in line 21 could belong to both.

Any way to fix this?

lanx@lanx-1005HA:~$ cat /tmp/tst_bxref.pl use strict; use warnings; my $a=1; print($a); sub bla { } { my $a=2; print($a); bla($a); } print($a); lanx@lanx-1005HA:~$ perl -MO=Xref,-d /tmp/tst_bxref.pl File /tmp/tst_bxref.pl Subroutine (main) Package (lexical) $a i5, i15, 8, 16, 17, 21 Package main &bla &17 /tmp/tst_bxref.pl syntax OK lanx@lanx-1005HA:~$ perl -MO=Xref,-d,-r /tmp/tst_bxref.pl /tmp/tst_bxref.pl (main) 5 (lexical) $ a + intro /tmp/tst_bxref.pl (main) 8 (lexical) $ a + used /tmp/tst_bxref.pl (main) 15 (lexical) $ a + intro /tmp/tst_bxref.pl (main) 16 (lexical) $ a + used /tmp/tst_bxref.pl (main) 17 (lexical) $ a + used /tmp/tst_bxref.pl (main) 17 main & bla + subused /tmp/tst_bxref.pl (main) 21 (lexical) $ a + used /tmp/tst_bxref.pl syntax OK

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re: Separating different lexicals with B::Xref
by LanX (Saint) on May 01, 2015 at 17:27 UTC
    hmm ... seems like I could use B::Concise for it, but I'm not able to find an explanation what the numbers in [$a:3,7] and [$a:5,6] are supposed to mean.

    help?

    lanx@lanx-1005HA:~$ perl -MO=Concise,-src /tmp/tst_bxref.pl |grep \$a /tmp/tst_bxref.pl syntax OK # 5: my $a=1; 4 <0> padsv[$a:3,7] sRM*/LVINTRO ->5 # 8: print($a); 8 <0> padsv[$a:3,7] l ->9 # 15: my $a=2; # 15: my $a=2; e <0> padsv[$a:5,6] sRM*/LVINTRO ->f # 16: print($a); i <0> padsv[$a:5,6] l ->j # 17: bla($a); m <0> padsv[$a:5,6] lM ->n # 21: print($a); s <0> padsv[$a:3,7] l ->t

    update

    the second number seems to be indicating the scope and the first one the symbol.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1125374]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-18 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found