在Windows 10上安装Active Perl中的Switch.pm

3

我正在尝试在Windows 10上使用Active Perl 5.28.1运行Perl脚本。它目前在Windows 7上使用Active Perl 5.8.8可以运行。但是当我尝试运行它时,出现以下错误:

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╞╔■î>∩îÅ=\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╞╔■î>∩îÅ=\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\ 但这没有效果,如果目录中有文件,则它们会根据需要进行更新。
我做错了什么? 罗伯特
注意:我发现需要向文本添加一些回车/换行符,否则我将收到一个关于代码格式不正确的错误消息。

1
你尝试过使用草莓Perl吗? - Håkon Hægland
3
该模块的名称是Switch,而不是Switch.pm(那是文件名)。请注意,在Perl中,switch-case的概念具有微妙的复杂性(参见此处),而Switch是这方面的一个旧实现,存在着更严重的问题 - Grinnz
草莓 Perl 不是一个选择。我们必须使用 Active State 的 Active Perl。 - Robert DiRosario
“安装开关”会产生相同的结果。我正在移植现有的代码,而不是编写新代码。这个Perl脚本有6000多行,如果可能的话,我宁愿不改变它。计划A是无需更改地移植代码。 - Robert DiRosario
“echo o conf | cpan”的输出是3300多个字符,但我只能发布600个字符。有什么方法可以发布大评论吗? - Robert DiRosario
显示剩余3条评论
1个回答

3
根据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模块可以轻松安装。
其他替代方案可能包括:
  • Perl 5.26中PPM仍然可用,可以在activestate.com找到
  • 使用5.28的CPAN命令,但对于许多模块,您需要makedmake。后者可能最容易通过http://www.mingw.org/获得
  • 使用WSL-Windows子系统以Linux。这里提供了适用于您所选Linux版本的aptyum命令。根据我的经验,这是一种简单可靠的安装Perl模块的方法。但这不是ActivePerl,它几乎不是Windows,它主要是Gnu / Linux
  • Strawberry-Perl适用于Windows
  • https://fastapi.metacpan.org/source/CHORNY/Switch-2.17/Switch.pm下载Switch似乎(根据我现在很快的一瞥)只是一个纯Perl模块,不依赖其他非核心模块。因此,您可以将文件下载并放置在perl -le'print for @INC'输出的文件夹之一中,并确保该文件对系统用户可读。

因此,最好的选择是第一个选项,前往https://platform.activestate.com/链接,登录,然后您将获得一个GUI,可以让您在其系统上构建模块,然后下载一个完整的Perl软件包,您可以安装在您的系统上。 - Robert DiRosario
我不会仅凭我所做的非常快速的测试就声称这是“最佳选择”,但它对我有效。如果你打算坚持使用ActiveState,那么最好还是了解一下他们的平台。此外,我在上面的答案列表底部添加了另一个替代方案。 - Kjetil S.
现在我明白了,太好了 :-) - Kjetil S.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接