Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Static analysis using PPI

by PerlOnTheWay (Monk)
on Dec 13, 2011 at 12:22 UTC ( [id://943316]=perlquestion: print w/replies, xml ) Need Help??

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

my $a = 1; .. my $b = func1($a); .. sub t{ my ($c) = @_; } t(func2($b));

Since Parse::Perl::Independant can parse Perl itself,is it possible to know that $c is first converted from $a and then converted from $b programatically(which is obvious for human)?

If yes,any advice?

Replies are listed 'Best First'.
Re: Static analysis using PPI
by Corion (Patriarch) on Dec 13, 2011 at 12:37 UTC

    Yes - look at type inference. For a language like Perl, real type inference and/or dataflow analysis will be limited, because eval can be used to overwrite call sequences in various places, as can glob assignment. But for a class of programs that don't do this, it is in theory possible.

Re: Static analysis using PPI
by bluescreen (Friar) on Dec 13, 2011 at 12:48 UTC

    Any static analysis over Perl code is not reliable Perl Cannot Be Parsed: A Formal Proof, in simple cases like this you might be able to trace the origins of a variable but as long as you attempt the same thing over more complex code you will get into trouble because the Perl parser adapts to the run time environment.

Re: Static analysis using PPI
by Anonymous Monk on Dec 13, 2011 at 13:35 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2025-04-26 10:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.