john-jones
john-jones

Reputation: 7780

get perl-script output into vimscript

I 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?

Upvotes: 1

Views: 302

Answers (1)

mu is too short
mu is too short

Reputation: 434685

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.

Upvotes: 4

Related Questions