Penguin
Diff: PerlOneLiners
EditPageHistoryDiffInfoLikePages

Differences between version 25 and predecessor to the previous major change of PerlOneLiners.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 25 Last edited on Thursday, May 19, 2005 5:56:59 pm by AristotlePagaltzis Revert
Older page: version 24 Last edited on Wednesday, May 11, 2005 2:57:40 pm by CraigBox Revert
@@ -43,15 +43,25 @@
 </verbatim> 
  
 Note that you can use any punctuation as the separator in an <tt>s///</tt> command, and if you have backslashes or even need literal slashes in your pattern then doing this can increase clarity. 
  
-!! sh -x a Perl script 
+!! Trace execution in a [ Perl] script 
  
-If you're just trying to get a printout of each line of Perl code as it executes (the way that sh -x provides for shell scripts), you can't use Perl 's -D switch. Instead do this
+Getting a trace showing each executed line of code in sequence (think <tt> sh -x</tt> but for [Perl] scripts) is not obvious. perl(1) 's <tt> -D</tt> switch itself does not provide such functionality, but you can get there like so
  
 <verbatim> 
 $ PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS program 
 </verbatim> 
+  
+Another option is to install the [Devel::Trace | http://search.cpan.org/dist/Devel-Trace/] module and simply use it on the script using the <tt>-d:Trace</tt> argument:  
+  
+<verbatim>  
+$ perl -d:Trace program  
+</verbatim>  
+  
+This does not work everywhere, but is has the advantage that you can easily influence the amount of trace output from within the script. [Perl] developers will therefore probably prefer to use the module.  
+  
+''This really belongs on a ~PerlNotes page, not here.''  
  
 !! List all currently running processes 
  
 This is useful if you suspect that ps(1) is not reliable, whether due to a RootKit or some other cause. It prints the process ID and command line of every running process on the system (except some "special" kernel processes that lie about/don't have command lines).