Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!ucsd!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!uvaarpa!mmdf From: martin%easby.durham.ac.uk@pucc.PRINCETON.EDU (Martin Ward) Newsgroups: comp.lang.perl Subject: (none) Message-ID: <1990Jul10.095016.2473@uvaarpa.Virginia.EDU> Date: 10 Jul 90 09:50:16 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: martin%easby.durham.ac.uk@pucc.PRINCETON.EDU Organization: The Internet Lines: 30 The perl man page suggests that the following are equivalent: open(FOO, "cat -n $file|"); open(FOO, "-|") || exec 'cat', '-n', $file; But this is not the case if $file contains whitespace or metacharacters. The first line will pass "cat -n $file" to the sh which will expand metacharacters and extract arguments to pass to cat, the second line passes the two arguments "-n" and "$file" directly to cat. Perusal of the section on exec suggests that: open(FOO, "-|") || exec "cat -n $file"; is truly equivalent to open(FOO, "cat -n $file|"); in that exec with one argument either extracts the arguments separated by white space in the string or (if the string contains metacharacters) passes the string to sh for argument extraction and filename globbing. If you don't want gratuitous globbing then the version: open(FOO, "-|") || exec 'cat', '-n', $file; is to be preferred (eg if $file came from @ARGV). Martin. My ARPANET address is: martin%EASBY.DUR.AC.UK@CUNYVM.CUNY.EDU OR: martin%uk.ac.dur.easby@nfsnet-relay.ac.uk UUCP:...!mcvax!ukc!easby!martin JANET: martin@uk.ac.dur.easby BITNET: IN%"MARTIN@EASBY.DURHAM.AC.UK"