login Signup

Perl error from parameter with trailing backslash

I am having an issue with trailing backslashes in parameters. If I pass a UNC path that has a trailing backslash in it (no trailing backslash works fine), I receive the following error:

 Bad name after AnswerFileUncPath' at C:\Windows\TEMP\ecmdrAgent/agent.JOTXTADGK7MTY5EH.run-a3e356c2-4720-11e7-8290-02ab20524153-a404c18e-4720-11e7-b53d-02ab20524153.cmd line 38.

I isolated the issue to the issue happening in the first line of the below code. While the second line (line 38) reports the error but I am not sure how to handle it. Note the value may be a file or a directory so trailing is not guaranteed but has to be allowed.


 AnswerFileUncPath = \\testServer\Builds\myBilds\AnswerFile\


 my $AnswerFile_UncPath         = '$[AnswerFileUncPath]';
 eval { $AnswerFile_UncPath = $cmdr->getProperty('/myJob/Idm/AnswerFileUncPath')->findvalue('//value')->value() };

avatar image By marc 328 asked Jun 02, 2017 at 12:32 AM
more ▼
(comments are locked)
10|750 characters needed characters left

1 answer: sort voted first

Try to use getProperty instead of the property substitution

by using property substitution, you pass the \' to the perl interpreter which causes your error By using a getProperty the \ simply goes into your variable

That typically how I dealt with "weird characters"

avatar image By lrochette 5.9k answered Jun 02, 2017 at 01:47 PM
more ▼
(comments are locked)
10|750 characters needed characters left
Your answer
toggle preview:

Up to 8 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.