On Thu, 24 May 2001, David Blevins wrote:

> So, as far as editing files in a subroutine of a script, there does not seem
> to be an easier or more performant way?
>
> Would it be performant to call the perl command as a subprocess, as in:
>
> `perl -ni -e 'print unless /I'm a bad line, delete me\./' thefile`;

For a simple script, you can use -n and -i in your shebang line.  If you
are doing something more complicated, like lots of sub calls and other
cool Perl things, you may want to create a generic sub to edit the file,
using the temp file method.  It's probably the safest and most scalable
way of doing it.

-- Brett

Reply via email to