in reply to Output redirection problem in Windows ActivePerl
Backslashes in double quotes behave differently from backslashes in single quotes. Your \t in c:\temp gets interpreted as tab character in double quoted strings. See perlop.
The solution is to check the command you're about to execute:
my $cmd = "ping $_ >c:\temp\log.txt"; print "About to run [$cmd]\n"; system($cmd) == 0 or die "Couldn't run [$cmd]: $!/$?/$^E";
In the short run, doubling all backslashes will do what you want:
my $cmd = "ping $_ >c:\\temp\\log.txt"; print "About to run [$cmd]\n"; system($cmd) == 0 or die "Couldn't run [$cmd]: $!/$?/$^E";
|
|---|