Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Static analysis using PPI

by PerlOnTheWay (Scribe)
on Dec 13, 2011 at 12:22 UTC ( #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 (Pope) 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?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2021-06-16 07:36 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (74 votes). Check out past polls.