oracle 运行 Perl 脚本时出现 Text/CSV.pm 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26218980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting Error on Text/CSV.pm when running Perl Script
提问by NerdyBird
When running a Perl Script that grabs content from an Oracle DB and exports the results into a CSV, I am getting this error when trying to run it via the command line:
当运行从 Oracle DB 获取内容并将结果导出到 CSV 的 Perl 脚本时,我在尝试通过命令行运行它时收到此错误:
Can't locate Text/CSV.pm in @INC (@INC contains:
/usr/lib/perl5/site_perl/5.16.2/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.16.2
/usr/lib/perl5/vendor_perl/5.16.2/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.16.2
/usr/lib/perl5/5.16.2/x86_64-linux-thread-multi /usr/lib/perl5/5.16.2
/usr/lib/perl5/site_perl/5.16.2/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.16.2 /usr/lib/perl5/site_perl .) at
./OracleScript.pl line 4. BEGIN failed--compilation aborted at
./OracleScript.pl line 4.
I interpret this to mean that the Module is not installed. So, I tried to install it with the following command:
我将此解释为未安装模块。因此,我尝试使用以下命令安装它:
/usr/bin/perl -MCPAN -e'install Text::CSV_pm'
I get this error:
我收到此错误:
Database was generated on Mon, 06 Oct 2014 10:41:02 GMT Warning:
Cannot install Text::CSV_pm, don't know what it is. Try the command
i /Text::CSV_pm/
to find objects with matching identifiers.
Can anybody shed some light on my issues, and how to remedy this?
任何人都可以对我的问题有所了解,以及如何解决这个问题?
回答by Dave Cross
Given that you're using the system Perl (and, from a comment, it seems you have root) then the easiest approach is probably to install the package that is pre-built for your Linux distribution.
鉴于您使用的是系统 Perl(并且,从评论来看,您似乎拥有 root 用户),那么最简单的方法可能是安装为您的 Linux 发行版预先构建的软件包。
For a Debian/Ubuntu-based system:
对于基于 Debian/Ubuntu 的系统:
$ sudo apt-get install libtext-csv-perl
For a RedHat/Centos/Fedora-based system:
对于基于 RedHat/Centos/Fedora 的系统:
$ sudo yum install perl-Text-CSV
回答by i alarmed alien
If you are installing a module with CPAN, the syntax is
如果您使用 CPAN 安装模块,则语法为
perl -MCPAN -e'install Module::Name'
No extension needed
无需扩展
So you need
所以你需要
perl -MCPAN -e'install Text::CSV'
Otherwise CPAN will search for a module called Text::CSV_pm, which (obviously) doesn't exist.
否则 CPAN 将搜索名为 Text::CSV_pm 的模块,该模块(显然)不存在。
You can also use cpan in interactive module, which is a little more friendly:
也可以在交互模块中使用cpan,友好一点:
perl -MCPAN -e shell
It's best to run it as root (i.e. sudo perl -MCPAN -e shell
) if you're trying to update your system perl, or set up cpan so that it writes to directories that you own (e.g. your home directory).
sudo perl -MCPAN -e shell
如果您尝试更新系统 perl 或设置 cpan 以便它写入您拥有的目录(例如您的主目录),最好以 root 身份运行它(即)。