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');
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
|