in reply to Using perl interactively with VI

How about as a one-liner?
perl -pi -le'$_=substr($_,0,index($_,"?")+1)' file.txt
(update: added +1 to preserve first question mark)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: Re: Using perl interactively with VI
by ambrus (Abbot) on Mar 14, 2004 at 13:14 UTC

    No -i switch if you call perl as a filter from an editor!

      Then what about:
      #!/usr/bin/perl -pi s/this/that/g;
      I honestly don't know how to call filters from vi ... so i don't know how to test this. But i think this should take care of the problem.

      UPDATE:
      Just figured out how to use filters in vi, that wasn't hard at all! Yes, this definetly takes care of the problem. :)

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)