Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!comp.vuw.ac.nz!ajv From: Andrew.Vignaux@comp.vuw.ac.nz (Andrew Vignaux) Newsgroups: comp.lang.perl Subject: Re: Question on variable substitution in strings Message-ID: <1991Jun18.073349.6447@comp.vuw.ac.nz> Date: 18 Jun 91 07:33:49 GMT References: <1991Jun18.051149.25411@ccu1.aukuni.ac.nz> Sender: news@comp.vuw.ac.nz (News Admin) Organization: Comp Sci, Victoria University, Wellington, New Zealand. Lines: 30 Nntp-Posting-Host: downstage.comp.vuw.ac.nz Originator: ajv@downstage.comp.vuw.ac.nz In article <1991Jun18.051149.25411@ccu1.aukuni.ac.nz>, russell@ccu1.aukuni.ac.nz (Russell J Fulton;ccc032u) writes: |> $ddev='ccvcom::sys\$sysdevice:[decnet.uspool]'; |> system("/usr/bin/dn/dncp $file $ddev$$__$printer"."__$USER"."__$vmsfn"); |> |> There are two things that puzzle me. One is why do I need to escape the |> $ in the first statement. $sysdevice is being interpreted by /bin/sh. |> The other thing is: why do I need to break the string with a "." after |> $printer? I could have understood it if I had to break up "$$__" because |> perl got confused between $$ and $_. Because '_' is a valid character in an identifier. An easier workaround is to use {}s: "...__${printer}__..." To avoid /bin/sh getting its grubbly little hands on your '$'s (or even worse someone invoking your utility with "USER='; echo gotcha'") you could invoke: system('/usr/bin/dn/dncp', $file, "$ddev$$__${printer}__${USER}__$vmsfn"); i.e. pass the arguments to dncp directly. Andrew -- Domain address: Andrew.Vignaux@comp.vuw.ac.nz