Inplace editing the elegant way

I would like to develop a script that can inplace edit a large file (potentially 1Gb), omitting some lines according to a regex and replacing some lines according to another regex. Here is an example of a script that does this with a couple of hardcoded patterns: { local ($^I, @ARGV) = ('', ($full_path_to_config_file));