Hi Sunita, On Tue, 15 May 2012 07:40:44 -0400 <sunita.prad...@emc.com> wrote:
> Hi > > I want to print the command during script execution . > Example : > > > =================== > $ls = `ls`; > > Print "$ls\n"; > ================== > I should note that trapping the output of "ls" is pretty silly because there are built-in routines and CPAN modules for doing that which are more portable and less error-prone than piping to the shell for input. You also want "print" in all lower-case instead of "Print" with an uppercase "P". > In the above script I want to print "ls" command before 'ls' command gets > executed . Like "set -x" does in shell scripts . > > Could you please help me on this ? > You can do it for each and every Perl statement using https://metacpan.org/module/Devel::TraceVars or maybe using https://metacpan.org/module/Devel::Trace . If you want to do it only for shell commands executed using backticks, then you can search for "qx" in http://perldoc.perl.org/overload.html (and you can also try setting a shell environment variable to add "-x" to all shell-executed commands). Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Chuck Norris/etc. Facts - http://www.shlomifish.org/humour/bits/facts/ You name it — COBOL does not have it. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/