I'm trying to replace a particular line in a text file on VMS. Normally, this is a simple one-liner with Perl. But I ran into a problem when the replacement side was a symbol containing a VMS path. Here is the file and what I tried:
Contents of file1.txt:
foo
bar
baz
quux
Attempt to substitute 3rd line:
$ mysub = "disk$data1:[path.to]file.txt"
$ perl -pe "s/baz/''mysub'/" file1.txt
Yields the following output:
foo
bar
disk:[path.to]file.txt
quux
It looks like Perl was overeager and replaced the $data1
part of the path with the contents of a non-existent variable (i.e., nothing). Running with the debugger confirmed that. I didn't supply /e
, so I thought Perl should just replace the text as-is. Is there a way to get Perl to do that?
(Also note that I can reproduce similar behavior at the linux command line.)