in reply to How to track variable usage in a script?
First, you can list all of the variables and subs in use in the script by executing the following command:
perl -MO=Xref myscript.pl >myscript.xref
That will dump all kinds of good information into 'myscript.xref'.
Armed with that info, you can pick and choose which variables you want to track. From that point, have a look at my node: "Scalars tied to logfiles" to see one way of logging scalar access via Perl's tie interface. This solution would have to be adapted and reworked a bit if you wanted to also log hashes and arrays.
Another alternative is that there's probably an easier way with something in the Devel namespace.
Update: Thanks for the "lazy link alert". I was in a rush this morning when I posted it, and didn't have a chance to check. I've fixed it now.
Update2: One module to look at might be Devel::FindGlobals. It appears that if you provide it with a hash of lexical names, it will look at them too. Not sure it will give you as much info as you want or not, but it might be a start.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How to track variable usage in a script?
by QM (Parson) on Mar 22, 2004 at 18:37 UTC | |
|
Re: Re: How to track variable usage in a script?
by Scarborough (Hermit) on Mar 22, 2004 at 16:52 UTC |