Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: A silly reg exp question

by AnomalousMonk (Abbot)
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!


Comment on Re^2: A silly reg exp question
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-12-22 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (114 votes), past polls