I run this command in my macOS
$ perl ~/Desktop/blif2cnf.pl
and got this error info:
Can't locate getopts.pl in @INC (@INC contains: /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.2 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at /Users/Frank/Desktop/blif2cnf.pl line 10.
In my linux 16.04, such problem can be solved by following this answer
Is there a module like libperl4-corelibs-perl
in macOS?
I know CPAN, but I don't know which module should I install.
It's Perl4::CoreLibs. In general the Debian package libthis-that-perl
corresponds to a module named This::That
, although it's up to you to figure out the capitalization :)
I'm not sure how the package manager works with macOS, but a platform-independent way of installing the getopts
package.
To answer the question you put as a comment to the answer from @hobbs, the way I searche for a module I need is either through the site that @hobbs linked, https://metacpan.org, or, alternatively, http://search.cpan.org. It was at the second that I found what I needed.
Searching for getopts.pl
gave a link to "Perl4::CoreLibs". In the upper-right-hand corner, there was a link that said Perl4-CoreLibs-0.003.tar.gz (though it looks like there is a 0.004 now). I right-clicked and selected "copy link address", which gave me
http://search.cpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.004.tar.gz
Whatever your link is, you'll need to untar it and find all the *.pl
files in the lib
directory into a directory, and either
1) Link to them from the command line, e.g.
perl -I /path/to/where/you/untarred/lib ~/Desktop/blif2cnf.pl
or
2) Add them to your PERLLIB
environment variable.
I think that more details will be helpful.
Detailed Instructions
Figure out a directory where you want to download your *.pl
files. I used $HOME/new_perl_stuff
cd ~
mkdir new_perl_stuff
cd new_perl_stuff
Now, get the tarball
wget http://search.cpan.org/CPAN/authors/id/Z/ZE/ZEFRAM/Perl4-CoreLibs-0.004.tar.gz
untar it, go into the directory, and make sure lib
is there
$ tar -xzf Perl4-CoreLibs-0.004.tar.gz
$ cd Perl4-CoreLibs-0.004
$ ls
You should see lib
in the list.
It's possible to add your newly downloaded lib
directory (in my case, $HOME/new_perl_stuff/Perl4-CoreLibs-0.004/lib
) to the perl
search path, but this just makes me worry about another directory that I might delete at some time. I made a new folder in the /usr/lib
directory. I decided to name the new directory libperl4-corelibs-perl
, since that seemed standard. First, I checked to make sure that there wasn't already a directory with that name.
$ stat /usr/lib/libperl4-corelibs-perl
stat: cannot stat '/usr/lib/libperl4-corelibs-perl': No such file or directory
Then I made the directory.
mkdir /usr/lib/libperl4-corelibs-perl
The next step was copying all the *.pl
files into this directory. I hope to explain this next command later. I ran it this way to make sure all of the files I needed were there. From my $HOME/new_perl_stuff/Perl4-CoreLibs-0.004
directory, I ran the following command, which I plan to come back and explain.
find ./lib -type f -name "*.pl" -print0 | xargs -I'{}' -0 \
bash -c 'new_dir=/usr/lib/libperl4-corelibs-perl/; chmod +x {}; \
echo "Moving {}"; mv {} ${new_dir} && echo -e "success\n" || \
echo -e "failure\n"' | tee moving_day.log
Run that one if you want to see that everything got copied successfully. A shorter command that does everything necessary is:
find ./lib -type f -name "*.pl" -print0 | xargs -I'{}' -0 \
bash -c 'new_dir=/usr/lib/libperl4-corelibs-perl/; chmod +x {}; \
mv {} ${new_dir}'
It's not a bad idea to run
ls -lah /usr/lib/libperl4-corelibs-perl
to check that the *.pl
files are there.
You can now run
perl -I /usr/lib/libperl4-corelibs-perl ~/Desktop/blif2cnf.pl
but there's an easier way.
Finally, I made it so that this directory will become part of the perl
search path every time I use a terminal by adding the following line to my ~/.bashrc
This command adds the path to the PERLLIB
environment variable. Different flavors of Linux have different syntax for adding to environment variables, make sure to find out what yours is!
export PERLLIB="/usr/bin/libperl4-corelibs-perl:$PERLLIB"
The commands I ran for this were
$ echo -e "\n\n## allow Perl to use the files in Perl4::CoreLibs" >> $HOME/.bashrc
$ echo -e "export PERLLIB=\"/usr/lib/libperl4_corelibs_perl:$PERLLIB\"" >> $HOME/.bashrc
$ source .bashrc
Now, you can simply run
perl ~/Desktop/blif2cnf.pl
Note: It's probably a good idea to go back and remove unwanted extras:
rm -rf $HOME/new_perl_stuff
来源:https://stackoverflow.com/questions/47990911/which-module-do-i-need-when-i-got-error-info-cant-locate-getopts-pl-in-inc