Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: A silly reg exp question

by AnomalousMonk (Chancellor)
on Jan 16, 2012 at 20:42 UTC ( #948204=note: print w/replies, xml ) Need Help??

in reply to Re: A silly reg exp question
in thread A silly reg exp question

s/8/7-/g; s/7/33-/g; s/6/5-/g; s/5/22-/g; s/4/3-/g; s/3/11-/g; s/2/1-/ +g; s/1/-/g;

This version certainly seems to work, but is it lazy, crazy, peevish, peccant, or...?

I think it's the version I would choose if I hated the person who would be maintaining my code!

Update: ++ for the whole reply for diversity and perversity!

Replies are listed 'Best First'.
Re^3: A silly reg exp question
by JavaFan (Canon) on Jan 16, 2012 at 20:58 UTC
    Feel free to replace the semicolons (except the last) with xors for even more perversity.

      ++ and amen, but only with  no warnings 'void'; since one cannot enjoy perversity incautiously.

      In fact, wouldn't any of the left-associative operators  * x + - . << >> & | ^ , => xor do as well so long as precedence levels were not mixed unwisely? Although I haven't thoroughly tested it, I like:

      >perl -wMstrict -le "$_ = 'p1r4k/8'; my $t = 'p-r----k/--------'; no warnings 'void'; s/8/7-/g-+s/7/33-/g-+s/6/5-/g-+s/5/22-/g-+s/4/3-/g-+s/3/11-/g-+s/2/1- +/g-+s/1/-/g; print qq{'$_'}; print $_ eq $t; " 'p-r----k/--------' 1

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948204]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-02-25 10:43 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (312 votes). Check out past polls.