I'm trying to write a function in gvim that would use the module File::Path.But
it alert me "Can't locate File/Path.pm in #INC(#INC contains: .) at (eval 8) line 1.
BEGIN failed--compilation aborted at (eval 8) line 1." when gvim start.
I know it means gvim couldn't find my perl lib path.
So,my question was :
How to tell gvim the correct path to locate the Perl modules?I have tried to add use lib'C:/Perl/lib'; but the problem continued.
Thank you~~~
if has("perl")
function! Make_dir()
perl make_dir();
endfunction
autocmd VimEnter * call Make_dir()
perl <<EOF
use File::Path;
sub make_dir{
my $bakup=$ENV{'HOME'}."/bakup" ;
mkdir $bakup if not -e _;
#VIM::SetOption("backup");
#VIM::SetOption("backupdir=$bakup");
#VIM::Msg($bakup);
#todo....
}
EOF
endif
Did you "censor" your output, or does it really say just "(#INC contains: .)"? That would seem to indicate a bad installation of Perl. It should have a few more directories in there. It could indicate a permission problem, I imagine.
use lib doesn't work because Perl can't find lib.pm or any other module it comes with. -I should work though, but it would only be a bandaid fix.
http://vim.wikia.com/wiki/Script:556
BTW,I tried the way on vim tips wiki also...but the problem continued
Related
I'm am currently trying to download a program that has given me many issues. I'm running cygwin on Windows. The program should run correctly and the installation packages were all installed in an administrator terminal shell, and as the program was being un'tar'ed no errors were thrown. However after the installation the program cannot find the #INC module named FASTA in the file system
rpbas#DESKTOP-4LMFDCK /cygdrive/c/Users/rpbas/Documents/Work/OliveraLab/signal-4.1
$ ./signal -t euk -f short test/euk10.fsa > euk10.fsa.short_out Can't locate FASTA.pm in #INC (you may need to install the FASTA module)
(#INC contains:
/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1/lib
\cygdrive\c\Users\rpbas\Documents\Work\Olivera/ Lab\signal-4.1
/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads
/usr/local/share/perl5/site_perl/5.26 /usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads
/usr/share/perl5/vendor_perl/5.26
/usr/lib/perl5/5.26/x86_64-cygwin-threads /usr/share/perl5/5.26)
at ./signal line 60.
BEGIN failed-- compilation aborted at ./signal line 60.
However, the ./lib/FASTA.pm file clearly exists and being directed to.
rpbas#DESKTOP-4LMFDCK /cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1/lib
$ ls
FASTA.pm
The code includes the line (at the beginning)
BEGIN {
$ENV{SIGNAL} = '/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1';
}
and at line 60
use lib "$ENV{SIGNAL}/lib";
use FASTA;
I've been working on this issue for a couple of days now and it a big bottleneck to the other parts of my program. Any help would be appreciated!
You are getting tripped up by the quote interpolation rules of Perl. Inside single quotes, a backslash character only acts as an "escape" character when it is followed by a single quote or by another backslash. In all other cases, it is interpreted as a literal backslash.
If you printed out $ENV{SIGNAL} you would see something like
/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1
including the backslash character. Don't escape the space and you should be all right.
BEGIN {
$ENV{SIGNAL} =
'/cygdrive/c/Users/rpbas/Documents/Work/Olivera Lab/signal-4.1';
}
#INC contains
/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1/lib
when it should contain
/cygdrive/c/Users/rpbas/Documents/Work/Olivera Lab/signal-4.1/lib
You could replace
BEGIN {
$ENV{SIGNAL} = '/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1';
}
use lib "$ENV{SIGNAL}/lib";
with
BEGIN {
$ENV{SIGNAL} = '/cygdrive/c/Users/rpbas/Documents/Work/Olivera Lab/signal-4.1';
}
use lib "$ENV{SIGNAL}/lib";
but a better solution is to replace it with
use FindBin qw( $RealBin );
use lib ( $ENV{SIGNAL} || $RealBin ) . "/lib";
I have a .pl script in which starts by:
#!/usr/bin/perl
use XML::XPath;
use Getopt::Long;
I can't seem to run that via perl myScript.pl, having this error:
(#INC contains: /usr/share/ /usr/local/lib64/perl5 /usr/local/share/perl5/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at most_generic_wrapper.pl line 3.
BEGIN failed--compilation aborted at myScript.pl line 3.
1- I tried to locate the XPath.pm file and export that as:
export PERL5LIB=/usr/share/perl5/XML/Twig
and
export PERL5LIB=/usr/share/perl5/XML
2- Installed perl -MCPAN -e 'install XML::Parser'
3- Used -I to explicitly define the path as:
perl -I perl -MCPAN -e 'install XML::Parser' myScript.pl
4- changing the line 3 to use XML::Twig::XPath; led to:
cannot use XML::Twig::XPath: neither XML::XPathEngine 0.09+ nor XML::XPath are available at /usr/share/perl5/XML/Twig/XPath.pm line 11.
BEGIN failed--compilation aborted at /usr/share/perl5/XML/Twig/XPath.pm line 13.`
But none of them solved the issue and I keep receiving the same error at line.3.
P.S: Running on CentOS 6.2 with the kernel 2.6.32-358 and perl --version=v5.10.1 (*) built for x86_64-linux-thread-multi
Any helps would be appreciated,
Your title says XML::XPath can't be found, but your question indicates you tried to install XML::Parser. Did you try to install XML::XPath?
From man perlrun: "If PERL5LIB is not defined, PERLLIB". You seem to have tried setting PERLIB5 (notice the spelling difference: the var is PERL5LIB (or PERLLIB), not PERLIB5).
From man perlrun: "PERL5LIB -- A list of directories in which to look for Perl library files before looking in the standard library and the current directory." You seem to have tried setting it to the full path to a .pm file, rather than a directory.
The file you assigned would be XML::Twig::XPath, not XML::XPath; those are two different Perl modules.
Edit: After looking at your revised question:
I'm not sure if your script requires XML::Twig::XPath or XML::XPath, or if either one can provide the API you need. However, XML::Twig::XPath seems to depend on XML::XPath so you will need XML::XPath no matter what, and it looks like XML::XPath is not installed on your system. I think that's probably the main problem. Please try to install XML::XPath using CPAN.
The value of the PERL5LIB variable (or the argument to the -I option) should be the directory that sits at the base of the package-qualified module file. For example, if XML::XPath is located at ~/perl_custom_modules/XML/XPath.pm, then you need to set PERL5LIB (or the -I argument) to ~/perl_custom_modules. The XML directory is part of the package qualification of the module, so does not need to be included in the include path.
Consider the following 2 scripts :
main.pl
#!/usr/bin/env perl
require 'lib.pl';
testSub('Hello World');
lib.pl
sub testSub
{
my ($input) = #_;
print $input, "\n";
}
1;
I need to run main.pl script remotely through SSH using sudo while including lib.pl as a dependency.
I know how to run a single Perl script through SSH using sudo :
$ ssh user#host 'sudo perl' < /path/to/local/perl/script
But, in this case, the following error is immediately raised :
Can't locate libs.pl in #INC (#INC contains: /usr/lib/perl5/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/5.10.0 /usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl .) at - line XX.
But how could I do the same while including another script as a dependency ?
Thanks all in advance.
Perl can only look at the local file system for includes and can not call back through a ssh channel to get data. So you either need to transfer the libs.pl to the other side before executing the program or just include its content directly in your program.
If you don't like to do this maybe Object::Remote can help you. But don't ask me how to use it, I've only heard a great talk about it.
I am trying to use ROUGE on Windows:
So the first few lines of the file:
use XML::DOM;
use DB_File;
use Getopt::Std;
#-------------------------------------------------------------------------------------
use vars qw($opt_a $opt_b $opt_c $opt_d $opt_e $opt_f $opt_h $opt_H $opt_m $opt_n $opt_p $opt_s $opt_t $opt_l $opt_v $opt_w $opt_2 $opt_u $opt_x $opt_U $opt_3 $opt_M $opt_z);
And it gives me this error:
Can't locate DB_File.pm in #INC (#INC contains: C:/Perl64/site/lib C:/Perl64/lib
.) at C:\RELEASE-1.5.5\ROUGE-1.5.5.pl line 174.
BEGIN failed--compilation aborted at C:\RELEASE-1.5.5\ROUGE-1.5.5.pl line 174.
I am new to perl. All i need is ROUGE to work. What does this mean? How can i fix it?
The author of the perl script probably did not test his script
on windows.
You could probably hack the script to make it work, but
since you're new to perl and seem to be in a hurry,
I suggest you use linux/unix for ROGUE.
The README for ROGUE mentions linuxy things like bash etc,
which is a clue.
If you insist, here's a way to get the perl script running
on windows, but be warned, further errors can pop up
as you get deeper in to the features.
remove activeperl
install strawberryperl 32bit
cpan install XML:DOM
cpan install DB_File
try:
close existing windows
open a new command prompt
run this command
ppm install DB_File
close window
try running rogue again
hope it helps
---
if you have a copy of the rogue application please share it so we can check it out.
I'm a perl noob and I have a very basic question regarding the #INC post: How is Perl's #INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?)
Does the "otherlibdirs" Configure option completely rewrite the directories that are part of #INC, or merely add another directory? It's not clear to me from that answer what it does, and I don't want to screw up the whole #INC path.
Thanks!
Perusing source of the Perl Configure script, we find the following usage information:
case "$otherlibdirs" in
''|' ') dflt='none' ;;
*) dflt="$otherlibdirs" ;;
esac
$cat <<EOM
Enter a colon-separated set of extra paths to include in perl's #INC
search path, or enter 'none' for no extra paths.
EOM
So if you compile Perl with something like
Configure -Dotherlibdirs=/usr/foo/bar:/usr/foo/bar/baz
Then the directories /usr/foo/bar and /usr/foo/bar/baz will be appended to the normal #INC built-in to the perl binary.