开发者

get perl-script output into vimscript

开发者 https://www.devze.com 2023-02-01 21:56 出处:网络
I开发者_Go百科 have tried the following: :let @0 = system(\'perl /home/hermann/hi.pl\') :echo @0 Having hi.pl like this:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消