I'm writing a Vim script. I have a function that uses embedded Perl. How do I return values from my Perl code?
The key is to escape any single quotes in the value you are trying to return, and then use VIM::DoCommand("return '$data'")
.
For example:
function PhoneHome()
perl << EOF
use IO::Socket;
my $mothership = IO::Socket->INET->connect()
my $data = <$mothership>;
$data =~ s|'|''|g; # escape '
VIM::DoCommand("return '$data'")
EOF
endfunction
Also see :help perl
and :help perl-DoCommand
. But for the most part this is not really documented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With