前言
最近,使用Perl运行脚本出现问题 23333
Error
Can't locate getopts.pl in @INC (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at xxxx.pl line 10.
Cause of error
getopts.pl is a Perl 4 core library but no longer included in current Perl 5 distributions.
Solve the error
Linux命令行输入“perl -MCPAN -e shell”进入perl界面,然后输入“install Perl4::CoreLibs”安装相应模块
→ Qftm ← :~/桌面# perl -MCPAN -e shell
CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.
Would you like to configure as much as possible automatically? [yes] yes
Autoconfiguration complete.
commit: wrote '/root/.cpan/CPAN/MyConfig.pm'
You can re-run configuration any time with 'o conf init' in the CPAN shell
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v2.20)
Enter 'h' for help.
cpan[1]> install Perl4::CoreLibs
Fetching with LWP:
http://www.cpan.org/authors/01mailrc.txt.gz
Reading '/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with LWP:
http://www.cpan.org/modules/02packages.details.txt.gz
Reading '/root/.cpan/sources/modules/02packages.details.txt.gz'
Database was generated on Tue, 31 Dec 2019 01:41:03 GMT
.............
New CPAN.pm version (v2.27) available.
[Currently running version is v2.20]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.
...............................................................DONE
Fetching with LWP:
http://www.cpan.org/modules/03modlist.data.gz
Reading '/root/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /root/.cpan/Metadata
Running install for module 'Perl4::CoreLibs'
Fetching with LWP:
http://www.cpan.org/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.004.tar.gz
Fetching with LWP:
http://www.cpan.org/authors/id/Z/ZE/ZEFRAM/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.004.tar.gz ok
Scanning cache /root/.cpan/build for sizes
DONE
'YAML' not installed, will not store persistent state
---- Unsatisfied dependencies detected during ----
---- ZEFRAM/Perl4-CoreLibs-0.004.tar.gz ----
Module::Build [build_requires]
Running install for module 'Module::Build'
Fetching with LWP:
http://www.cpan.org/authors/id/L/LE/LEONT/Module-Build-0.4229.tar.gz
Fetching with LWP:
http://www.cpan.org/authors/id/L/LE/LEONT/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/L/LE/LEONT/Module-Build-0.4229.tar.gz ok
Configuring L/LE/LEONT/Module-Build-0.4229.tar.gz with Makefile.PL
# running Build.PL --installdirs site
Checking optional features...
inc_bundling_support....disabled
requires:
! inc::latest is not installed
ERRORS/WARNINGS FOUND IN PREREQUISITES. You may wish to install the versions
of the modules indicated above before proceeding with this installation
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Module-Build' version '0.4229'
LEONT/Module-Build-0.4229.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for L/LE/LEONT/Module-Build-0.4229.tar.gz
/usr/bin/perl Build --makefile_env_macros 1
Building Module-Build
LEONT/Module-Build-0.4229.tar.gz
/usr/bin/make -- OK
Running make test
/usr/bin/perl Build --makefile_env_macros 1 test