简体   繁体   English

在Perl中打开文件时出现问题。

[英]Problem opening a file in Perl.

I am working with VMware Fusion virtual machines and I need to access a file located in the following path: 我正在使用VMware Fusion虚拟机,并且需要访问以下路径中的文件:

/Users/administrator/Documents/Virtual\\ Machines.localized/Win7_Pro_SP1_64.vmwarevm/Win7_Pro_SP1_64.vmx

I am using the Perl command : 我正在使用Perl命令:

open IN, "<","<above mentioned path>"

but it doesnt work. 但它不起作用。 If I copy the .vmx file to another location outside of the .vmwarevm, then it works. 如果将.vmx文件复制到.vmwarevm之外的其他位置,则它可以工作。 I have a feeling that since .vmwarevm is actually an application and by default opens with VMware Fusion, ie why perl command is not able to open it. 我有一种感觉,因为.vmwarevm实际上是一个应用程序,并且默认情况下会通过VMware Fusion打开,即为什么perl命令无法打开它。

I cant copy it and use, so is there a way to open file from such a path. 我无法复制和使用它,所以没有办法从这样的路径打开文件。 My operating system is Mac OSX 我的操作系统是Mac OSX

You can try this: 您可以尝试以下方法:

open my $in, '<', '/Users/administrator/Documents/Virtual Machines.localized/Win7_Pro_SP1_64.vmwarevm/Win7_Pro_SP1_64.vmx'
    or die;

if there is just space in Virtual Machines , no need to escape it. 如果Virtual Machines只有空间,则无需对其进行转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM