Reputation: 2540
I am trying to change the working directory (for configure a WebShpere MQ Queue manager) using Perl in UNIX.
I have to go to the directory /var/mqm/qmgrs/Q\!MAN
and I have used following code snippet:
$QueueManagerPathName = 'Q\!MAN';
chdir('/var/mqm/qmgrs/'.$QueueManagerPathName) or die "Cannot change to dir : /var/mqm/qmgrs/".$QueueManagerPathName."\n";
But it does not change the directory and dies giving
Cannot change to dir : /var/mqm/qmgrs/Q\!MAN
When i remove the variable $QueueManagerPathName
its working fine and it concludes me that it would be error using "\!"
part.
Upvotes: 1
Views: 1401
Reputation: 149776
You don't need to escape !
in the directory name. This should work:
my $dir = '/var/mqm/qmgrs/Q!MAN';
chdir $dir or die "Can't cd to $dir: $!\n";
Upvotes: 2
Reputation: 3364
Single quoted strings do not interpolate backslash, so you're trying to change to a directory called /var/mqm/qmgrs/Q\!MAN
Either omit the backslash, or use a double-quoted string.
Upvotes: 2
Reputation: 144
You have a backslash in your variable... I'd say that you are doing to much escaping.
Upvotes: 0