J
jrpfinch
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));
while (<>)
{
s/this/that/;
s/foo/bar/;
print unless ((/delete me/) or (/Delete Me Too/));
}
}
What is the best way to scale this for n patterns? When I say best, I
mean a good balance of speed and readability. Can I put all the
omission patterns in an array and all the search/replace patterns in
another array and somehow wedge them into the example above?
Any help appreciated.
Jon
(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));
while (<>)
{
s/this/that/;
s/foo/bar/;
print unless ((/delete me/) or (/Delete Me Too/));
}
}
What is the best way to scale this for n patterns? When I say best, I
mean a good balance of speed and readability. Can I put all the
omission patterns in an array and all the search/replace patterns in
another array and somehow wedge them into the example above?
Any help appreciated.
Jon