Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The "flaming X-wing" secret operator

3 views
Skip to first unread message

Philippe Bruhat

unread,
Nov 28, 2007, 11:16:18 AM11/28/07
to f...@perl.org
Hi,

Just thought I should share this with the FWP crowd.

I had to do something special with the first line of a file, before
running the whole while(<>) loop on it. I ended up with this:

@data{@fields} =<>=~ $re;

Rafael helped me give this new operator a name (#perlfr transcript):

15:13 <@BooK> OMG c'est quoi =<>=~ comme secret op ?
15:14 <@rgs> le x-wing touché avec une aile en feu

Rough translation:

15:13 <@BooK> OMG what is =<>=~ for a secret op ?
15:14 <@rgs> the hit x-wing starfighter with a wing on fire

Cog, are you still writing this OGSOP book? ;-)

--
Philippe Bruhat (BooK)

No matter how many times you explain the big problem, some people see only
their small problem.
(Moral to the Sage story, in Groo The Wanderer #93 (Epic))

Mr. Shawn H. Corey

unread,
Nov 28, 2007, 5:09:57 PM11/28/07
to Philippe Bruhat (BooK), f...@perl.org
Philippe Bruhat (BooK) wrote:
> Hi,
>
> Just thought I should share this with the FWP crowd.
>
> I had to do something special with the first line of a file, before
> running the whole while(<>) loop on it. I ended up with this:
>
> @data{@fields} =<>=~ $re;
>
> Rafael helped me give this new operator a name (#perlfr transcript):
>
> 15:13 <@BooK> OMG c'est quoi =<>=~ comme secret op ?
> 15:14 <@rgs> le x-wing touché avec une aile en feu
>
> Rough translation:
>
> 15:13 <@BooK> OMG what is =<>=~ for a secret op ?
> 15:14 <@rgs> the hit x-wing starfighter with a wing on fire
>
> Cog, are you still writing this OGSOP book? ;-)
>

Actually, it's:

@data{@fields} = ( <> =~ $re );


--
Just my 0.00000002 million dollars worth,
Shawn

+------------\
| Shangri La \
| 40,000 km /
+------------/

Yanick Champoux

unread,
Nov 28, 2007, 7:22:54 PM11/28/07
to Mr. Shawn H. Corey, Philippe Bruhat (BooK), f...@perl.org
Mr. Shawn H. Corey wrote:

> Philippe Bruhat (BooK) wrote:
>> @data{@fields} =<>=~ $re;
>
> Actually, it's:
>
> @data{@fields} = ( <> =~ $re );

Somehow, I think Philippe knew that. ;-)

So we had the spaceship operator, and now the flaming x-wing... Hmmm...
I'm beginning to suspect that the '@' sigil doesn't stand for a moon,
after all...


Joy,
`/anick

Mr. Shawn H. Corey

unread,
Nov 28, 2007, 7:04:29 PM11/28/07
to Yanick Champoux, Philippe Bruhat (BooK), f...@perl.org
Yanick Champoux wrote:
> Mr. Shawn H. Corey wrote:
>> Actually, it's:
>>
>> @data{@fields} = ( <> =~ $re );
>
> Somehow, I think Philippe knew that. ;-)

But, sadly, not everyone else who reads this list :(

>
> So we had the spaceship operator, and now the flaming x-wing...
> Hmmm... I'm beginning to suspect that the '@' sigil doesn't stand for a
> moon, after all...

No, it stands for Tranquility base, where "The Eagle has landed." (That would be the bullseye in the center of the circle. The outer circle is the moon. ;)

Philippe Bruhat

unread,
Nov 29, 2007, 4:00:19 AM11/29/07
to f...@perl.org
On Wed, Nov 28, 2007 at 07:22:54PM -0500, Yanick Champoux wrote:
> Mr. Shawn H. Corey wrote:
>> Philippe Bruhat (BooK) wrote:
>>> @data{@fields} =<>=~ $re;
>>
>> Actually, it's:
>>
>> @data{@fields} = ( <> =~ $re );
>
> Somehow, I think Philippe knew that. ;-)

Even better, I knew I didn't need them.

Do you think I would have submitted a starfighter that looked like this?

=(<>=~)

> So we had the spaceship operator, and now the flaming x-wing... Hmmm...
> I'm beginning to suspect that the '@' sigil doesn't stand for a moon, after
> all...

That's no moon! It's a space station.

--
Philippe Bruhat (BooK)

When you invite relatives, they never seem to leave your home, so long as it
is still standing. (Moral from Groo The Wanderer #20 (Epic))

Jose Castro

unread,
Nov 29, 2007, 4:26:43 AM11/29/07
to f...@perl.org

On Nov 28, 2007, at 4:16 PM, Philippe Bruhat (BooK) wrote:

> Hi,
>
> Just thought I should share this with the FWP crowd.
>
> I had to do something special with the first line of a file, before
> running the whole while(<>) loop on it. I ended up with this:
>
> @data{@fields} =<>=~ $re;
>
> Rafael helped me give this new operator a name (#perlfr transcript):
>
> 15:13 <@BooK> OMG c'est quoi =<>=~ comme secret op ?
> 15:14 <@rgs> le x-wing touché avec une aile en feu
>
> Rough translation:
>
> 15:13 <@BooK> OMG what is =<>=~ for a secret op ?
> 15:14 <@rgs> the hit x-wing starfighter with a wing on fire
>
> Cog, are you still writing this OGSOP book? ;-)

/me takes notes, as the answer is a yes.


> --
> Philippe Bruhat (BooK)
>
> No matter how many times you explain the big problem, some people
> see only
> their small problem.
> (Moral to the Sage story, in Groo The Wanderer
> #93 (Epic))

-------------------------------------------
José Castro <jose....@log.pt>
Applicational Development Leader
log <www.log.pt>

Tel: +351 21 330 42 20
Fax: +351 21 330 42 19
Calçada Marquês de Abrantes, 45 - 3º Dto
1200-718 Lisboa
-------------------------------------------


Philippe Bruhat

unread,
Nov 29, 2007, 4:05:21 AM11/29/07
to f...@perl.org
On Thu, Nov 29, 2007 at 09:54:25AM +0100, Philippe Bruhat (BooK) wrote:
>
> # DATA is the pilot, for the sake of the example
> @data{@fields} =<DATA>=~ $re;
>

Did I just inadvertently make a Star Wars/Star Trek cross-over?

--
Philippe Bruhat (BooK)

He who revels in being bigger forgets that he is the larger target.
(Moral from Groo #5 (Image))

Philippe Bruhat

unread,
Nov 29, 2007, 3:54:25 AM11/29/07
to f...@perl.org
On Wed, Nov 28, 2007 at 05:09:57PM -0500, Mr. Shawn H. Corey wrote:
> Philippe Bruhat (BooK) wrote:
>> Hi,
>>
>> Just thought I should share this with the FWP crowd.
>>
>> I had to do something special with the first line of a file, before
>> running the whole while(<>) loop on it. I ended up with this:
>>
>> @data{@fields} =<>=~ $re;
>>
>> Rafael helped me give this new operator a name (#perlfr transcript):
>>
>> 15:13 <@BooK> OMG c'est quoi =<>=~ comme secret op ?
>> 15:14 <@rgs> le x-wing touché avec une aile en feu
>>
>> Rough translation:
>>
>> 15:13 <@BooK> OMG what is =<>=~ for a secret op ?
>> 15:14 <@rgs> the hit x-wing starfighter with a wing on fire
>>
>> Cog, are you still writing this OGSOP book? ;-)
>>
>
> Actually, it's:
>
> @data{@fields} = ( <> =~ $re );
>

Actually, it's not:

use strict;
use warnings;
use Data::Dumper;

my @fields = qw( H M S );
my $re = qr/(\d\d):(\d\d):(\d\d)/;
my %data;



# DATA is the pilot, for the sake of the example
@data{@fields} =<DATA>=~ $re;

print Dumper \%data;

__DATA__
the time is now 03:14:15

Which outputs:

$VAR1 = {
'H' => '03',
'M' => '14',
'S' => '15'
};

Why would I need parentheses, when the hash slice gives me a list
context already?

--
Philippe Bruhat (BooK)

For every winner, there must be one or more losers.
(Moral to the Sage story in Groo #111 (Epic))

Dmitry Karasik

unread,
Nov 29, 2007, 7:09:20 AM11/29/07
to f...@perl.org

Philippe> @data{@fields} =<>=~ $re;

That gives me a reason to pick symmetrical names for my filehandles in the future:

=<W>=~
=<O__O>=~
=<IX000H000XI>=~

that'll be an X-wing squadron :)

--
Sincerely,
Dmitry Karasik

Philippe Bruhat

unread,
Nov 29, 2007, 7:44:53 AM11/29/07
to f...@perl.org
On Thu, Nov 29, 2007 at 01:09:20PM +0100, Dmitry Karasik wrote:
>
> Philippe> @data{@fields} =<>=~ $re;
>
> That gives me a reason to pick symmetrical names for my filehandles in the future:
>
> =<W>=~
> =<O__O>=~
> =<IX000H000XI>=~
>
> that'll be an X-wing squadron :)
>

Or you could go down the fan fic way, and imagine the Empire is about
to win, now that the Red Squadron is severily hit:

=<Biggs_Darklighter>=~
=<Jek_Porkins>=~
=<Wedge_Antilles>=~
=<Luke_Skywalker>=~

--
Philippe Bruhat (BooK)

In war, the only winners are those who sell the weapons.
(Moral from Groo #3 (Image))

Mr. Shawn H. Corey

unread,
Nov 29, 2007, 9:20:20 AM11/29/07
to Philippe Bruhat (BooK), f...@perl.org
Philippe Bruhat (BooK) wrote:
> Why would I need parentheses, when the hash slice gives me a list
> context already?
>

The parentheses, like the whitespace, are for clarification; to make it easier to understand what is happening. Also, it is not one operator, it is three.

Why do you use so much whitespace in your program when most of it is not needed?

Philippe Bruhat

unread,
Nov 29, 2007, 9:32:31 AM11/29/07
to f...@perl.org
On Thu, Nov 29, 2007 at 09:20:20AM -0500, Mr. Shawn H. Corey wrote:
> Philippe Bruhat (BooK) wrote:
>> Why would I need parentheses, when the hash slice gives me a list
>> context already?
>>
>
> The parentheses, like the whitespace, are for clarification; to make
> it easier to understand what is happening.

Clarification is off-topic when you wander in the realm of golfing and
secret operators.

> Also, it is not one operator, it is three.

I don't think you fully understand what secret operators are, then. :-)

For some background on secret operators, you can read the following
thread in the archives:

http://groups.google.com/group/perl.fwp/browse_thread/thread/4416004e60b67101

--
Philippe Bruhat (BooK)

To flaunt your strength is to make it your weakness.
(Moral from Groo The Wanderer #25 (Epic))

yan...@babyl.dyndns.org

unread,
Nov 29, 2007, 11:11:44 AM11/29/07
to Philippe Bruhat (BooK), f...@perl.org
On Thu, Nov 29, 2007 at 10:00:19AM +0100, Philippe Bruhat (BooK) wrote:
> On Wed, Nov 28, 2007 at 07:22:54PM -0500, Yanick Champoux wrote:
> > Somehow, I think Philippe knew that. ;-)
>
> Even better, I knew I didn't need them.

I knew you knew. :-) I was more saying "Philippe knows that
it's not really one operator but a bag o' various stuff (as the
parenthesizing shows)".

> Do you think I would have submitted a starfighter that looked like this?
>
> =(<>=~)

Only if you would have called it "Tie Bomber with a sidecar".

> > So we had the spaceship operator, and now the flaming x-wing... Hmmm...
> > I'm beginning to suspect that the '@' sigil doesn't stand for a moon, after
> > all...
>
> That's no moon! It's a space station.

Heh. That's the quote I had in mind too. But now that a Space
1999 reference has been made, I'm desperatly trying to come up with
an Eagle operator. Alas, so far the best I can find is

$wooooosh =~ mm==mo

which is pretty sad. :-/

Joy,
`/anick

yan...@babyl.dyndns.org

unread,
Nov 29, 2007, 11:30:41 AM11/29/07
to Mr. Shawn H. Corey, Yanick Champoux, f...@perl.org
On Wed, Nov 28, 2007 at 07:04:29PM -0500, Mr. Shawn H. Corey wrote:
> Yanick Champoux wrote:
> >
> > Somehow, I think Philippe knew that. ;-)
>
> But, sadly, not everyone else who reads this list :(

True. But then, subscription to this mailing list
should come with a massive chunk of sodium chloride and
the warning "Hic sunt dementis". :-)

Joy,
`/anick

Paul Johnson

unread,
Nov 29, 2007, 10:09:28 AM11/29/07
to Mr. Shawn H. Corey, Philippe Bruhat (BooK), f...@perl.org
On Thu, Nov 29, 2007 at 09:20:20AM -0500, Mr. Shawn H. Corey wrote:

> The parentheses, like the whitespace, are for clarification; to make it
> easier to understand what is happening. Also, it is not one operator, it
> is three.

Have you, perhaps, forgotten which mailing list this is? Understandable
if you have, given the previous thread (with the exception of shmem's
glorious next_power_of_two subroutine).

--
Paul Johnson - pa...@pjcj.net
http://www.pjcj.net

Shmem

unread,
Nov 29, 2007, 11:08:22 AM11/29/07
to yan...@babyl.dyndns.org, Philippe Bruhat (BooK), f...@perl.org
From the keyboard of yan...@babyl.dyndns.org [29.11.07,11:11]:

To brighten up your day - here's the winged moon, which isn't an
operator, but a constant:

~@~

;-)

0--gg-

--
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s,/,($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e,e && print}

Georg Moritz

unread,
Nov 29, 2007, 11:21:31 AM11/29/07
to f...@perl.org
From the keyboard of yan...@babyl.dyndns.org [29.11.07,11:11]:

> On Thu, Nov 29, 2007 at 10:00:19AM +0100, Philippe Bruhat (BooK) wrote:

Similar to the winged moon - an "operator" (token?) which scares
the hell out of the remainder of a list:

^@^

qwurx [shmem] ~ > perl -le 'print "foo","bar", ^@^ ,"we are","gone..."'
foobar

;~)

Yanick Champoux

unread,
Nov 29, 2007, 8:01:45 PM11/29/07
to f...@perl.org
shmem wrote:
> To brighten up your day - here's the winged moon, which isn't an
> operator, but a constant:
>
> ~@~

Georg added:


> Similar to the winged moon - an "operator" (token?) which scares
> the hell out of the remainder of a list:
>
> ^@^


Me likes. Lots. I propose, as alternative names for those two tokens,
the "fat bat" (because it does look like a particularly rotund specimen
of that species, and in honor of the large value it yields) and
the"laughing joker" (as in, "just kidding, the rest of the line doesn't
apply). :-)

Joy,
`/anick

Shmem

unread,
Nov 30, 2007, 12:48:18 AM11/30/07
to Yanick Champoux, f...@perl.org
From the keyboard of Yanick Champoux [29.11.07,20:01]:

> shmem wrote:
> > To brighten up your day - here's the winged moon, which isn't an
> > operator, but a constant:
> >
> > ~@~
>
> Georg added:
> > Similar to the winged moon - an "operator" (token?) which scares
> > the hell out of the remainder of a list:
> >
> > ^@^

in fact, shmem and Georg are the same guy, though 'Georg' just slipped ;-)

> Me likes. Lots. I propose, as alternative names for those two tokens,
> the "fat bat" (because it does look like a particularly rotund specimen of
> that species, and in honor of the large value it yields) and the"laughing
> joker" (as in, "just kidding, the rest of the line doesn't apply). :-)

Names OK. I'm glad you didn't come up with 'spacestation broken solar
panels' or such ;-D

> Joy,
> `/anick

Philippe Bruhat

unread,
Nov 30, 2007, 3:51:06 AM11/30/07
to f...@perl.org
On Fri, Nov 30, 2007 at 09:43:36AM +0100, Philippe Bruhat (BooK) wrote:
> >
> > Me likes. Lots. I propose, as alternative names for those two tokens, the
> > "fat bat" (because it does look like a particularly rotund specimen of that
> > species, and in honor of the large value it yields) and the"laughing joker"
> > (as in, "just kidding, the rest of the line doesn't apply). :-)
>
> Of course, we now need canonical usage examples of those two.
>

One usage could combine them two. When you need to use the largest
possible integer on 32 bits, you can use them both. Of course, it's a
slight golf (1 character winned), but a real golfer will do much better.

2**32-1 # UINT_MAX
~@~^@^ # fat bat & laughing joker
~0 # golf hole

--
Philippe Bruhat (BooK)

The right answer is worthless with the wrong question!
(Moral from Groo The Wanderer #88 (Epic))

Philippe Bruhat

unread,
Nov 30, 2007, 3:43:36 AM11/30/07
to f...@perl.org

Of course, we now need canonical usage examples of those two.

--
Philippe Bruhat (BooK)

Blood is thicker than water... so beware of thick relatives.
(Moral from Groo The Wanderer #18 (Epic))

Yanick Champoux

unread,
Nov 30, 2007, 9:17:47 PM11/30/07
to shmem, f...@perl.org
shmem wrote:
> in fact, shmem and Georg are the same guy, though 'Georg' just slipped ;-)

One would think that the same sig and style and everything would have
tipped me off. But nooooo... That was too suble for me still. <:-P

>> Me likes. Lots. I propose, as alternative names for those two tokens,
>> the "fat bat" (because it does look like a particularly rotund specimen of
>> that species, and in honor of the large value it yields) and the"laughing
>> joker" (as in, "just kidding, the rest of the line doesn't apply). :-)
>
> Names OK. I'm glad you didn't come up with 'spacestation broken solar
> panels' or such ;-D

Oh, I considered it. But at the end, I thought that the other
suggestions were rolling off the tongue a wee bit better. ;-)


Joy,
`/anick

0 new messages