Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!ateng!tct!chip From: chip@tct.uucp (Chip Salzenberg) Newsgroups: comp.lang.perl Subject: Re: Command substitution or Common novice bug Message-ID: <26124BA2.56FE@tct.uucp> Date: 29 Mar 90 17:53:38 GMT References: <1460@kuling.UUCP> Organization: ComDev/TCT, Sarasota, FL Lines: 28 According to jand@kuling.UUCP (Jan Dj{rv): >Should command substitution work inside double quotes? Unix shells distinguish between "`command`" and "command" because sometimes you feel like a nut... er, sometimes you want to keep spaces, tabs, etc. and sometimes you want to collapse them. Given Perl's strength in string manipulation, whitespace collapse is better written explicitly: Shell Perl ----- ---- x="`ls`" $x = `ls`; chop($x); x=`ls` $x = `ls`; chop($x); $x =~ s/[\s\n]+/ /g; As for the interpolation in quoted strings, that's easy to simulate: sub B { local($x); $x = `@_`; chop($x); $x; } print "Today is " . &B("date") . ", or so Unix claims.\n"; Pack another jack huster, -- Chip Salzenberg at ComDev/TCT , "The Usenet, in a very real sense, does not exist."