note
gmax
<p>As you can learn from your example with <u>sort</u>, the external command takes your lines from the standard input. </p>
<p>Change your script this way:</p>
<code>
#!/usr/bin/perl -w
use strict;
while (<>) {
chomp;
print "file is [$_]\n";
if ( ! -e $_ ) {
print "#$_\n";
} else {
print "$_\n";
}
}
</code>
<p>However, if your Vim has <a href="http://vimdoc.sourceforge.net/htmldoc/if_perl.html#perl-compiling">direct Perl support</a>, you can execute something like this:</p>
<code>
:1,$ perldo s/^/#/ unless -e $_
</code>
<p>See [id://141765] for an explanation and more examples on similar features.</p>
<div class="pmsig"><div class="pmsig-127116">
<pre>
_ _ _ _
(_|| | |(_|><
_|
</pre>
</div></div>
374750
374750