Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Inplace editing the elegant way
October 9, 2008, 2:16 pm
rate this thread
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));
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.
- Hartmut Camphausen
October 10, 2008, 5:23 pm
Re: Inplace editing the elegant way
J=FCrgen Exner schrieb:
I'd consider to store the /compiled/ patterns + replacement strings in=20
an array - if efficiency is an issue.
Else each pattern would have been recompiled for each chunk of data.
jm2p + mfg, Hartmut
Hartmut Camphausen h.camp[bei]textix[punkt]de
- » How to make all available CPU resource to Perl/MySQL in Win XP?
- — Previous thread in » PERL Discussions