Hello Monks,
I have a web application in perl, with lot of perl modules. There is one module which has a hash called %session in the package. I want to find all methods across all modules whose code can change the contents of the hash. The change can be done in any of the following ways
$session{x} = 1;
or
$y = $session{x}; # $session{x} is an object $y->set_z(3); # this changes the state of object $y
or
$y = $session{x}; foo($y); sub foo { $y->set_z(3); # this changes state of object $y }
I would like it, if this can be automated instead of manually going through the code for all methods. What I was trying was to go through all links from the application UI so that all methods will be executed. I injected some debugging code which will compare the serialized version of the hash before and after the execution of the methods. If there was a difference the method name will be logged. But then the code is bound to change in future and so would require repetition of above process. It would be better if there was any automatic way like a script that would inspect the code(also "use" the modules if needed) and find the list. To me this looked quite challenging! But I think there will be really smart minds to crack this.
Thanks very much in advance!
Ganesh

In reply to Find whether code can change a module variable by ganeshk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.