develooper Front page | | Postings from June 2009

Re: Another one-liner?

Thread Previous | Thread Next
Philippe Bruhat
June 24, 2009 14:35
Re: Another one-liner?
Message ID:
On Wed, Jun 24, 2009 at 04:26:05PM +0100, Jasper wrote:
> 2009/6/24 Daniel Tiefnig <>:
> >
> >  perl -00 -ne'/.{65535}/||print'
> >
> of course becomes
> perl -00 -pe'$_ x=!/.{65535}/'

Did you notice that this (x=!) is a secret operator of the same family
as the "screwdriver operators" discovered by Dmitry Karasik and showed
some time ago (November 2007) on fwp.

Actually, Dmitry only showed three of them:

> This bunch, I think, can be appropriately named "screwdriver operators":
>    -=! and -=!!        - flathead
>    +=! and +=!!        - phillips
>    *=! and *=!!        - torx

When preparing my talk on the Perl secret operators for the last French
Perl Workshop (and hopelessly looking for nice pictures of screwdrivers),
I realized that, in real life, there are several types or cruciform
(or cross-head) screwdrivers. It had to be the same in Perl!

Ladies and gentlemen, it is my pleasure to introduce you to the fourth
screwdriver operator, the Pozidriv (

   x=! and x=!!        - pozidriv

This is a conditional "set to empty string" operator (the string
equivalent of the torx):

  $x x=!! $y  is same as $x = '' unless $y;
  $x x=!  $y       --    $x = '' if $y;

I hope you'll welcome it in your toolbox, like Jasper did.

 Philippe Bruhat (BooK)

 The fish most likely to be caught is the one with the biggest mouth.
                                    (Moral from Groo The Wanderer #17 (Epic))

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About