Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: making my script work with vi

by gmax (Abbot)
on Jul 15, 2004 at 18:18 UTC ( #374768=note: print w/replies, xml ) Need Help??


in reply to making my script work with vi

As you can learn from your example with sort, the external command takes your lines from the standard input.

Change your script this way:

#!/usr/bin/perl -w use strict; while (<>) { chomp; print "file is [$_]\n"; if ( ! -e $_ ) { print "#$_\n"; } else { print "$_\n"; } }

However, if your Vim has direct Perl support, you can execute something like this:

:1,$ perldo s/^/#/ unless -e $_

See Editing features for advanced users for an explanation and more examples on similar features.

 _  _ _  _  
(_|| | |(_|><
 _|   

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://374768]
help
Chatterbox?
[LanX]: AnomalousMonk: yeah the asteroid but not the god, right?
[jedikaiti]: :-)
[AnomalousMonk]: LanX: Of course the asteroid! There is/are no god(s).
erix suddenly wants to hear My Sweet Lord once more

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (17)
As of 2017-11-22 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (327 votes). Check out past polls.

    Notices?