Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by QM (Parson)
on May 23, 2013 at 12:34 UTC ( [id://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?

-QM
--
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 (Canon) 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.

      -QM
      --
      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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://1034937]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-03-28 22:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found