In Perl, you can execute system commands using system() or “ (backticks). You can even capture the output of the command into a variable. However, this hides the program execution in the background so that the person executing your script can’t see it.
Normally this is useful but sometimes I want to see what is going on behind the scenes. How do you make it so the commands executed are printed to the terminal, and those programs’ output printed to the terminal? This would be the .bat equivalent of ‘@echo on’.
As I understand, system() will print the result of the command, but not assign it. Eg.
Backticks will capture the output of the command and not print it:
etc…
Update: If you want to print the name of the command being
system()‘d as well, I think Rudd‘s approach is good. Repeated here for consolidation: