in reply to qx command outputs

Is there a way to redirect the output of a qx command to a logfile.

Would   system("$doscommand > $logfile"); work? It's a little less work than

open(LOG, ">$logfile") or die "$logfile: $!"; print LOG `$doscommand`; close LOG;

Replies are listed 'Best First'.
Re: Re: qx command outputs
by belg4mit (Prior) on Jan 15, 2002 at 21:42 UTC
    Using the shell to redirect the output could be very bad. It's rather insecure and you are relying upon the shell to parse more. For example, this appears to be M$, if $logfile contains any spaces this will fail, you would need:
    print system(qq($doscommand > "$logfile"));
    Though I think
    #replace . w/ . if 5.6++ open(LOG, '>>'. $logfile); print LOG qx($doscommand);
    would be better.

    --
    perl -pe "s/\b;([st])/'\1/mg"