Front page | perl.golf |
Postings from June 2009
Re: Another one-liner?
Thread Previous
|
Thread Next
From:
Philippe Bruhat
Date:
June 24, 2009 14:35
Subject:
Re: Another one-liner?
Message ID:
20090624213529.GP14812@plop
On Wed, Jun 24, 2009 at 04:26:05PM +0100, Jasper wrote:
> 2009/6/24 Daniel Tiefnig <dantie@gmx.at>:
> >
> > 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 (http://en.wikipedia.org/wiki/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