Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Memorizing The s/// Option List For Fun and Profit

by QM (Parson)
on May 23, 2013 at 12:34 UTC ( #1034937=perlmeditation: print w/replies, xml ) Need Help??

Did you ever want to memorize the s/// option list? The full list (from perlop) is msixpodualgcer.

Here are some anagrams I found:
* discourage p/m/xl (petite, medium, extra-large)
* glamorised x cpu
* Proclaimed, "g sux!" (oft heard?)
* xl CPU ideograms (extra-large CPU)
* goru x misplaced ("guru is misplaced")
* ex-cpu marigolds
* dog pux miracles (poo or pukes)

Can anyone come up with something better?

Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re: Memorizing The s/// Option List For Fun and Profit
by tobyink (Abbot) on May 23, 2013 at 15:02 UTC

    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
      I must say, I'm a bit disappointed ;) Leaving out obvious wins like "miracles" and "ideograms"?

      And I realize I forgot to try more e's. Heck, I suppose technically all of them can be repeated. Trying a bit harder and a bit looser, there's magicexposure, geodesicmap, supermelodic, and my favorite so far, maliciouspleasure.

      Quantum Mechanics: The dreams stuff is made of

        Bear in mind that some regexp modifiers are mutually exclusive; for example /a which imposes ASCII semantics on the string being matches, and /l which imposes locale semantics on it. Thus s/foo/bar/miracles is a compile time error.

        Here's a quick script to find allowable words...

        #!/usr/bin/env perl use v5.18; open my $dict, "<", "/usr/share/dict/words"; while (<$dict>) { next unless /^[msixpodualgcer]+$/; chomp; my $ok = do { my $testing = $_; local $_; # protection eval "s/foo/bar/$testing; 1"; }; say if $ok; }

        I rather like these ones:

        • amigos
        • carcass
        • circus
        • corridor
        • crisscross
        • gigolo
        • girls
        • idiom
        • igloo
        • macrocosm
        • macroscopic
        • mammograms
        • microcosm
        • microscopic
        • orgasmic
        • pompous
        • program
        • sarcasm
        • scissors

        Now to find a way to patch B::Deparse...

        package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1034937]
Front-paged by Arunbear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2018-06-18 16:17 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (110 votes). Check out past polls.