I开发者_Go百科 have tried the following:
:let @0 = system('perl /home/hermann/hi.pl')
:echo @0
Having hi.pl like this:
\#!/usr/bin/perl
exit(34);
But I dont get 34 into @0
, I get nothing.
How do I return a value from a perl script to a vimscript?
Firstly, :echo @0v
is just a typo that should be :echo @0
, right?
Secondly, system() in vimscript returns the standard output of the command not the command's return value. Your let @0 ...
is equivalent to one of these in perl:
my $x = `perl /home/hermann/hi.pl`;
my $y = qx:perl /home/hermann/hi.pl:;
If you want the return value rather than the command's standard output, look at the v:shell_error variable.
精彩评论