dimar has asked for the wisdom of the Perl Monks concerning the following question:
Question:
Can someone provide a very simple proof-of-concept perl sample that works as a text filter for (g)Vim?
Background:
H is editing text with Vim. Vim can filter a region of text using (among other things) the built-in Vim-script language or an external program. H already has a trusty arsenal of perl scripts that can do various text-filtering operations, and H wants to use those instead of essentially re-writing them all in Vim-speak.
Problem:
H is able to get Vim filtering to work with other external programs, but not with perl. For example:
The root of the problem appears to be that H cannot figure out how to get the input from Vim through STDIN.!sort <-- this Vim command calls a binary, OK !myfilter.pl <-- this Vim command calls a perl script, FAIL
Proposed Solution:
H simply wants to see a bare-bones simple perl script that can filter text successfully from Vim (just like !sort can do) just to prove that it can indeed be done. It doesn't have to be sort, just something simple like:
#!/usr/local/perl ### myfilter.pl my $sTest = ''; while(<STDIN>){$sTest .= $_;} print " _IT_WORKED_ $sTest _IT_WORKED_ ";
Constraints:
20050219 Edit by castaway: Changed title from 'HOWTO: A simple, perl-based text filter for Vim'
|
|---|