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))
Actually, it's:
@data{@fields} = ( <> =~ $re );
--
Just my 0.00000002 million dollars worth,
Shawn
+------------\
| Shangri La \
| 40,000 km /
+------------/
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
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. ;)
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))
> 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
-------------------------------------------
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))
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))
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
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))
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?
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))
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
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
> 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
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}
> 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
;~)
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 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
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))
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))
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