In Perl, you can execute external commands using system() or “. However, system and “ does not redirect command output to console and this results people who runs your perl script can’t see it. This also make debug much harder. Perl does not have a build in switch that equals to batch scripts’ “@echo on”, however this can be worked around by creating a ExecuteCommand subroutine.
sub ExecuteCommand {
my $cmd= $_;
my @cmdoutput = `$cmd`;
for $line (@cmdoutput) {
print $line;
}
Now just change your code from system($command) or `$command` to ExecuteCommand($command) and you will see all command output are redirected to console. (more…)