http://www.perlmonks.org?node_id=10262


in reply to Dark Theme for /. through Perl

One thing that might make this more clear (as well as more generally customizable) is to separate the theme changes from the main script.

Build a configuration file, then read it into the hash. The key will be the string-to-find and the value will be the replacement. Then you can do something as simple as this:

foreach my $find (keys %chunks) { $data =~ s/$find/$chunks{$find}/g; }
You don't have anything complicated like backtracking or grouping, so it works. It's a bit slower than the other way, but the added convenience (and code beautification) might be worth it.