in reply to Redirecting STDOUT
Do you really need for Perl to be able to detect that its output is being thrown away (and thus not bother copying it) or do you just not want the output? How many times per minute does this need to run, and how many megabytes of data does it add up to that you're throwing away total? Because, if you just don't need the output, you can save yourself a good deal of messing around by just calling system in void context.
do_stuff(); system($command, @args); do_more_stuff();
In theory Perl _could_ detect that system is called in void context not as the last item in the block and so could optimise away copying the command's output. In practice I don't know whether it does or not, but this only matters if you have a significant performance or footprint issue due to the size of the output being large or the system call being repeated quite often. If not, do it and don't sweat it. Don't optimise things that don't need to be optimised; it makes your code that much longer and less clear for no good reason.
{my$c;$ x=sub{++$c}}map{$ \.=$_->()}map{my$a=$_->[1]; sub{$a++ }}sort{_($a->[0 ])<=>_( $b->[0])}map{my@x=(& $x( ),$ _) ;\ @x} split //, "rPcr t lhuJnhea eretk.as o";print;sub _{ord(shift)*($=-++$^H)%(42-ord("\r"))};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Redirecting STDOUT
by mifflin (Curate) on May 03, 2003 at 01:36 UTC |