On Sun, May 15, 2011 at 01:31:47PM -0400, Jim Green wrote: > this is very nice, don't need to call perl in perl anymore.. > > perl -pi -e '$_ = "" if /foo/' filename > > but what if the file is very large? slurping the file in to memory will > be ok? > > or is there any other alternatives you are aware of? or you can dismiss?
{ local ($^I, @ARGV) = ("", "filename"); while (<>) { print unless /foo/; } } is the idiomatic way to do that. Well, to do: perl -ni -e 'print unless /foo/' filename which is the idiomatic way to do what you had written. For a more direct translation, substitute the loop contents with $_ = "" if /foo/; print; -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/