in reply to Memorizing The s/// Option List For Fun and Profit
Take a peek at the source code for B::Deparse, a module that takes an in-memory Perl optree and outputs a string of Perl source equivalent to it. Given the /g /i, /m and /r modifiers, it could easily output something like: s/foo/bar/gimr but instead, with typical Perl finesse, it will, if possible, rearrange the modifiers to form a word: s/foo/bar/grim.
The list of words it will try is repeated below...
my %matchwords; map($matchwords{join "", sort split //, $_} = $_, 'cig', 'cog', 'cos', + 'cogs', 'cox', 'go', 'is', 'ism', 'iso', 'mig', 'mix', 'osmic', 'ox', 'sic +', 'sig', 'six', 'smog', 'so', 'soc', 'sog', 'xi'); # ... my %substwords; map($substwords{join "", sort split //, $_} = $_, 'ego', 'egoism', 'em +', 'es', 'ex', 'exes', 'gee', 'go', 'goes', 'ie', 'ism', 'iso', 'me', 'meese', 'meso', 'mig', 'mix', 'os', 'ox', 'oxime', 'see', 'seem', 'seg', 'sex', 'sig', 'six', 'smog', 'sog', 'some', 'xi', 'rogue', 'sir', 'rise', 'smore', 'more', 'seer', 'rome', 'gore', 'grim', 'g +rime', 'or', 'rose', 'rosie');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Memorizing The s/// Option List For Fun and Profit
by QM (Parson) on May 24, 2013 at 08:09 UTC | |
by tobyink (Canon) on May 24, 2013 at 10:35 UTC | |
by demerphq (Chancellor) on May 24, 2013 at 13:54 UTC |