Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!comp.vuw.ac.nz!waikato.ac.nz!aukuni.ac.nz!russell From: russell@ccu1.aukuni.ac.nz (Russell J Fulton;ccc032u) Newsgroups: comp.lang.perl Subject: Question on variable substitution in strings Message-ID: <1991Jun18.051149.25411@ccu1.aukuni.ac.nz> Date: 18 Jun 91 05:11:49 GMT Organization: University of Auckland, New Zealand. Lines: 38 I have been writing a perl program to implement a generic print command for our UNIX system. On of the ways we print files is by doing a DEC NET copy of the file to a vax where a process picks up the file and puts it in a VMS queue. (You *really* *don't* want to know why we do it this way!) Anyway I cobble to getter a long file name with various information coded into it and then invoke the decnet copy program with system. here is the fragment of code. $ddev='ccvcom::sys\$sysdevice:[decnet.uspool]'; print "/usr/bin/dn/dncp $file $ddev$$__$printer"."__$USER__$vmsfn\n"; 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. If I don't then the print statement prints the string correctly, in the call to system the $sysdevice is interpreted as a variable and substituted with a null string. 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 $_. BTW all the variables in these exprssions contain /\w/. I am running perl 4.03. I have this application running now but I would like to understand why I need to do this and hopefully say myself some time when I next fall over some thing similar. Thanks, Russell. -- Russell Fulton, Computer Center, University of Auckland, New Zealand.