|The stupid question is the question not asked|
making perl interactive with VIby NovMonk (Chaplain)
|on Feb 17, 2004 at 18:57 UTC||Need Help??|
NovMonk has asked for the
wisdom of the Perl Monks concerning the following question:
(see updates below):
I want to write a program I can call while editing a file with VI and have it perform some actions on the lines of text I have selected, something like
Where would I go to find some good examples of how to think about this? I can write something that would look though a whole file, but I want to be more selective about what gets changed. I want it to look at each line within those 17 and do things if it matches certain Regular Expressions.
This may seem hopelessly archaic (it is), but I work for a company where we are making tons of these changes by hand, and a utility that would do this for us Might make people more willing to looks at more interesting uses for Perl. I've got a couple of seds that do it now, but a one shot program would be Much better.
Thanks in advance.
Ha! I figured it out. Some of it anyway. This works:
Thanks Paladin-- your example with the <> got me on the right track of profitable trial and error. And I will look more closely at the command line switches, too, sleepingsquirrel. I'd still appreciate more comments and ideas. Thanks again.
Does anyone have any idea why the file so edited has a blank space at the beginning of each line? Here's a simpler (and cooler) program for reference:
I am kind of proud of figuring out a way to get it to delete lines containing "net" when
didn't work (Sorry, I learned sed first.) Thanks again, everyone.
Blank space was in the test file I was using. Nevermind. Thanks.