|Don't ask to ask, just ask|
Re^3: Splitting program into modulesby stevieb (Canon)
|on Nov 14, 2018 at 03:23 UTC||Need Help??|
So I've put together a very basic display of how the Devel::Trace::Subs works. Again, it's intrusive; it actually writes into the files you want to capture tracing info from (I wrote this software that another piece of software required, primarily out of sheer curiosity).
Here's the original Perl file we're working with (./test.pl):
When run, it produces this output:216
Very basic. Now, install Devel::Trace::Subs, and from the command line, tell it to become traceable:perl -MDevel::Trace::Subs=install_trace -e 'install_trace(file => "test.pl")'
...now the test.pl file looks like this:
I'd like to point out that the design for this software was to be used within modules not normal scripts, but I digress. In order to get the output from the tracing, you have to add a couple of things to your calling script (in this case, it's the original script itself). We'll pretend we're calling modules infected with the trace software here. Add the trace enabling flag, then after all of your calls have been made you want to get the trace info from, call the dump_trace() function::wq
Now, you get the original output, but you also get the code flow and stack trace information:
You can opt via parameters to trace_dump to display just the code flow or the stack trace or both (as is the default as shown above), in text or HTML output formats.
This is a *very* basic example of how I've used this software. Again, we're using it in a single file here. Normally I'd have a test script using external modules, so the command to return your original code is this:perl -MDevel::Trace::Subs=remove_trace -e 'remove_trace(file => "test.pl")'
...which returns the script back to default, except for the manual lines (which wouldn't normally be in an original .pl file). Delete these lines manually:
I'll try to put together a much better example of how I really use it in the coming days.