为什么我不能简单地将已安装的Perl模块复制到其他计算机? [英] Why can't I simply copy installed Perl modules to other machines?

查看:121
本文介绍了为什么我不能简单地将已安装的Perl模块复制到其他计算机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Perl来说是新手,但对动态语言却不是,我对模块的管理不那么直接感到惊讶.

Being very new to Perl but not to dynamic languages, I'm a bit surprised at how not straight forward the manage of modules is.

当然,cpan X在理论上可以正常工作,但是我正在使用三个不同的机器和操作系统(在工作中,在家中,在外部环境中进行测试)来从事同一个项目.

Sure, cpan X does theoretically work, but I'm working on the same project from three different machines and OSs (at work, at home, testing in an external environment).

  • 在工作中(Windows 7),由于我们的防火墙使ftp无法使用,我在使用cpan时遇到了问题
  • 它在家里(Mac OS X)确实可以工作
  • 在外部环境(Linux CentOs)中,它工作了几个小时才开始工作,因为我没有root访问权限,因此我必须将cpan配置为以非root用户身份运行
  • 我已尝试在其他可以访问的服务器上进行访问.如果以前的外部环境是VPS,因此我具有外壳访问权限,那么另一个是廉价的共享主机,除了预先安装的模块之外,我无法安装新模块
  • At work (Windows 7) I have problem using cpan because of our firewall that makes ftp unusable
  • At home (Mac OS X) it does work
  • In the external environment (Linux CentOs) it worked after hours because I don't have root access and I had to configure cpan to operate as a non-root user
  • I've tried on another server where I have an access. If the previous external environment is a VPS and so I have a shell access, this other one is a cheap shared hosting where I have no way to install new modules other than the ones pre-installed

目前,我仍然无法在Windows下安装模板.我已经看到,作为一种替代方案,我可以对其进行编译,并且我还尝试了ActiveState的PPM,但是该模块不存在.

At the moment I still can't install Template under Windows. I've seen that as an alternative I could compile it and I've also tried ActiveState's PPM but the module is not existent there.

现在,我的困惑在于Perl是一种动态语言.我在工作时遇到了所有这类问题,例如在C中,我必须编译所有平台的所有库,但是我认为使用Perl时,该方法将与Python或PHP的方法非常相似,而在90年代将模块复制到目录中并将其导入的案例所占的百分比很简单.

Now, my perplexity is about Perl being a dynamic language. I've had all these kind of problems while working, for example, with C where I had to compile all the libraries for all the platform, but I thought that with Perl the approach would have been very similar to Python's or PHP's where in 90% of the cases copying the module in a directory and importing it simply works.

所以,我的问题是:如果Perl的模块是用Perl编写的,为什么复制/粘贴方法不起作用?如果必须编译模块的某些(或某些部分),如何在CPAN中查看模块是否仅基于Perl或依赖于已编译的库?是否没有下载模块(tar,zip ...)并使用cpan进行部署的方法?这将解决我在Windows下的问题.

So, my question: if Perl's modules are written in Perl, why the copy/paste approach will not work? If some (or some part) of the modules have to be compiled, how to see in CPAN if a module is Perl-only or it relies upon compiled libraries? Isn't there a way to download the module (tar, zip...) and use cpan to deploy it? This would solve my problem under Windows.

推荐答案

现在,Perl是一种动态语言,但这并不意味着人们编写的所有内容都可以跨平台移植.那不是语言的错.这甚至不是程序员的错.诸如 Win32 :: OLE 之类的东西在Unix上不起作用. :)

Now, Perl is a dynamic language, but that doesn't imply that everything that people write is portable across platforms. That's not the fault of the language. It's not even the fault of the programmer. Some things, like Win32::OLE shouldn't work on Unix. :)

其他动态语言也会有一些相同的问题.如果必须编译C代码,则将无法仅将文件复制到另一台计算机.某些发行版根据您的操作系统等对代码的配置稍有不同.

Other dynamic languages will have some of the same problems. If you have to compile C code, you won't be able to merely copy files to another machine. Some distributions configure the code slightly differently depending on your operating system, etc.

即使可以复制文件,也必须确保复制所有需要的文件.您知道特定模块所需的一切吗?请记住,其中许多都具有依赖性.

Even if you could copy files, you have to ensure that you copy all of the files that you need. Do you know everything that you need for a particular module? Remember, many of them have dependencies.

您遇到的大多数问题与语言无关.您在使用工具时遇到了麻烦.如果您希望使用零配置CPAN工具来为您做出所有决定,请尝试 cpanminus .从cpan中得到的东西基本上是相同的(尽管代码不同),但是它可以为您做出所有决定.它不会运行任何发行测试,并且会安装到您的用户目录中.当您需要一些可以控制的内容时,请回到cpan.

Most of the problems you're having aren't anything to do with the language. You're having trouble with the tools. If you want a zero conf CPAN tool that makes all the decisions for you, try cpanminus. It's mostly the same thing that you'd get out of cpan (although different code), but it makes all of the decisions for you. It doesn't run any of the distribution tests, and it installs into your user directory. When you need something that gives you control, come back to cpan.

这篇关于为什么我不能简单地将已安装的Perl模块复制到其他计算机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆