Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
"Finally (and most importantly) using backticks for commands where you're not capturing the output is wasteful as Perl collects up all the output and returns it to you - only for you to throw it away. Better to use system in that case. Or to use Perl version of the command where they are available - like using move (from File::Copy instead of mv)."
Be thankful that Perl throws it away. If you do the same thing in (e.g.) ksh then the command for the shell to execute is evaluated as the return from the back-ticked command. i.e. it doesn't throw the output away it executes it! Now I can see how this might be useful in some obscure circumstances.....however I have seen back-ticks used without the realization of the implications :-( And yes, it did take me a while to work out where the obscure error messages were coming from! Cheers Dave.R
Nothing succeeds like a budgie with no teeth.
2006-10-03 Retitled by planetscape, as per Monastery guidelines: one-word (or module-only) titles hinder site navigation In reply to Backticks (Was: Re^2: Is this the most elegant way to code directory lookup?)
by LittleGreyCat
|
|