首页 > 解决方案 > 在 Windows 10 上的 Active perl 中安装 Switch.pm

问题描述

我正在尝试使用 Active Perl 5.28.1 在 Windows 10 上运行 Perl 脚本。它目前在带有 Active Perl 5.8.8 的 Windows 7 上运行。当我尝试运行它时,我得到:

Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: C:\Perl\lib C:/Perl64/site/lib C:/Perl64/lib) at fds_propagator_with_collision_ephem.pl line 108.

所以我尝试安装Switch.pm. 我开始cpan然后做了install Switch.pm

我有:

C:\Users\rdirosar>cpan
Loading internal logger. Log::Log4perl recommended for better logging

cpan shell -- CPAN exploration and modules installation (v2.20)
Enter 'h' for help.

cpan> install Switch.pm

Reading 'C:\Perl64\cpan\sources\authors\01mailrc.txt.gz'
Use of uninitialized value $command in concatenation (.) or string at C:\Perl64\lib/CPAN/Tarzip.pm line 163, <IN> line 1.

'-qdt' is not recognized as an internal or external command,
operable program or batch file.
............................................................................DONE

Reading 'C:\Perl64\cpan\sources\modules\02packages.details.txt.gz'
Use of uninitialized value $command in concatenation (.) or string at C:\Perl64\lib/CPAN/Tarzip.pm line 163.
'-qdt' is not recognized as an internal or external command,
operable program or batch file.

Warning: Your C:\Perl64\cpan\sources\modules\02packages.details.txt.gz does not contain a Line-Count header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
Warning: Your C:\Perl64\cpan\sources\modules\02packages.details.txt.gz does not contain a Last-Updated header.
Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.
.Could not split line["┬0\cL²\cU\c?└'≈\cCé"]

Could not split line["c▐X'Γπ"├█\cP\cE?▀&δ┌╠5α%â╛mτl∞Bô⌠ñg▒R\cI¥\cT\cP╘≈\cX."]


Could not split line["V╟\c]\$≈»1"]

Could not split line["a\cVk\cQ0y│ôδNj+╒1<c;¼òPb╪Zà⌠∞\cBl≥┤h\cRU\cPFÄ┴▄4û\cIƒ\@⌐╜─b*QZ\$lEX╞╔■î&gt;∩îÅ=\cF┬N;│¼-\cZu¿fÆh\eD"]

Giving up parsing your C:\Perl64\cpan\sources\modules\02packages.details.txt.gz, too many errorsReading 'C:\Perl64\cpan\sources\authors\01mailrc.txt.gz'

Use of uninitialized value $command in concatenation (.) or string at C:\Perl64\lib/CPAN/Tarzip.pm line 163.


'-qdt' is not recognized as an internal or external command,
operable program or batch file.
............................................................................DONE

Reading 'C:\Perl64\cpan\sources\modules\02packages.details.txt.gz'

Use of uninitialized value $command in concatenation (.) or string at C:\Perl64\lib/CPAN/Tarzip.pm line 163.


'-qdt' is not recognized as an internal or external command,
operable program or batch file.

Warning: Your C:\Perl64\cpan\sources\modules\02packages.details.txt.gz does not contain a Line-Count header.

Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to happen.

Warning: Your C:\Perl64\cpan\sources\modules\02packages.details.txt.gz does not contain a Last-Updated header.

Please check the validity of the index file by comparing it to more
than one CPAN mirror. I'll continue but problems seem likely to
happen.

.Could not split line["┬0\cL²\cU\c?└'≈\cCé"]

Could not split line["c▐X'Γπ"├█\cP\cE?▀&δ┌╠5α%â╛mτl∞Bô⌠ñg▒R\cI¥\cT\cP╘≈\cX."]

Could not split line["V╟\c]\$≈»1"]

Could not split line["a\cVk\cQ0y│ôδNj+╒1<c;¼òPb╪Zà⌠∞\cBl≥┤h\cRU\cPFÄ┴▄4û\cIƒ\@⌐╜─b*QZ\$lEX╞╔■î&gt;∩îÅ=\cF┬N;│¼-\cZu¿fÆh\eD"]

Giving up parsing your C:\Perl64\cpan\sources\modules\02packages.details.txt.gz, too many errorsLockfile removed.

C:\Users\rdirosar>

我尝试删除以下文件: 如果目录中有文件,它们会根据需要进行更新,但这没有效果C:\Perl64\cpan\sources\authorsC:\Perl64\cpan\sources\modules\

我究竟做错了什么?罗伯特

注意:我发现我需要在文本中添加一些 cr/lf,否则我会收到关于代码格式不正确的错误消息。

标签: perl

解决方案


根据https://www.activestate.com/blog/goodbye-ppm-hello-state-tool/ ActivePerl 5.28 移除了旧的 PPM 交互式 GUI 模块安装工具,转而使用新的https://platform.activestate.com /您登录、选择模块、构建、等待并最终将您自己的自定义运行时下载为一个大的 .exe 或 .msi 文件的网站(无论如何在 Windows 上)。

此安装文件包括 ActivePerl 5.28您选择的模块。

在我在 Windows 10 上的测试中,该Switch模块的安装没有遇到这样的问题。

其他替代方案可能是:

  • 我认为 PPM a 仍然可用的 Perl 5.26,请在 activestate.com 上找到它
  • 使用 5.28 中的 CPAN 命令,但对于许多(如果不是大多数)模块,您需要makedmake. 后者可能最容易通过http://www.mingw.org/获得
  • 为 linux使用 WSL- windows 子系统。可以使用适合您的 linux 风格的或类似的命令aptyum安装 Perl 模块的简单可靠的方法。在我的经验中。但这不是 ActivePerl,它几乎不是 Windows,主要是 Gnu/Linux
  • 适用于 Windows 的草莓 Perl
  • Switch 似乎(现在通过快速浏览判断)只是一个不依赖于其他非核心模块的纯 perl 模块。因此,您可以从https://fastapi.metacpan.org/source/CHORNY/Switch-2.17/Switch.pm下载文件并将其放在输出的文件夹之一中,perl -le'print for @INC'并确保系统用户可以读取该文件.

推荐阅读