I'm working on the reformatting of a number of documents.
I not only have to repetitively apply a number of regexes to a number of pages, but apply some regexes to some pages and not others.
There's no right or wrong answer of course, but how might Monks go about this in an organised and maintainable way, apart of course from the straightforward process of just doing:
and the variation$html =~ s/foo/bar/; $html =~ s/baz/quux/; $html =~ s/monkey/pants/;
$html =~ s/foo/bar/; if($baz_quux_replacement_required){ $html =~ s/baz/quux/; } $html =~ s/monkey/pants/;
Would monks for instance use a data structure like this:
or even this:$replacements = [ ['foo','bar'], ['baz','quux'] ];
and then iterate through them? Would you create a sub and feed it the RHS and LHS as arguments every time? Or just a for() loop?$replacements = { fix_foo => ['foo','bar'], fix_baz => ['baz','quux'] };
I'd be interested in Monkly opinions.
($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
=~y~b-v~a-z~s; print
In reply to Apply A Set Of Regexes To A String by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |