Not really sure what you're looking for, but maybe something like the Perl debugger's tracing facility?

For example, with a silly little program like this

#!/usr/local/bin/perl sub add { return $_[0] + $_[1]; } sub result { my $sum = shift; $sum = add($sum, shift) while @_; return $sum; } print result(@ARGV);

running it as follows under the debugger, would produce:

$ PERLDB_OPTS="NonStop AutoTrace frame=29" perl -d ./silly.pl 2 3 4 Package ./silly.pl. 13: print result(@ARGV); in @=main::result(2, 3, 4) from ./silly.pl:13 8: my $sum = shift; 9: $sum = add($sum, shift) while @_; in $=main::add(2, 3) from ./silly.pl:9 4: return $_[0] + $_[1]; scalar context return from main::add: 5 in $=main::add(5, 4) from ./silly.pl:9 4: return $_[0] + $_[1]; scalar context return from main::add: 9 10: return $sum; list context return from main::result: 0 9 9

(Note that the technique to set environment variables (PERLDB_OPTS) depends on the shell being used.)

This shows step by step what is being executed.

There are also less verbose modes. See perldebug for the meaning of the debugging options like frame etc.


In reply to Re^2: How to create a log file? by Eliya
in thread How to create a log file? by anurag_perl

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.