{
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
I'd probably store the REs pattern and replacement text as key/value
pairs in a hash(*) and just loop through them.
And a separate hash or array for the "delete" patterns.
*: that should work, because REs are just strings, too.
jue
> I'd probably store the REs pattern and replacement text as key/value
> pairs in a hash(*) and just loop through them.
> And a separate hash or array for the "delete" patterns.
>
> *: that should work, because REs are just strings, too.
I'd consider to store the /compiled/ patterns + replacement strings in
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
Nice idea!
jue
This is fine for simple line based parsing.
How would you handle replacements that span lines?
sln