Re: Secret operators: the documentation

2012-04-06 Thread Michael R . Wolf
On Mar 16, 2012, at 4:44 AM, Philippe Bruhat (BooK) wrote:

 A few years back, I started to write a manual page about Perl secret 
 operators,
 with the goal of getting it into the official Perl documentation at some 
 point.



A few comments…

1.  It would be nice to do a bit of documentation on *why* or *how* some of 
these work.  Perhaps a Deparse would be sufficient (as in Eskimo greeting), but 
English is also a good tool.

For starters, I didn't figure out how Ornate double-bladed sword worked.  I'm 
sure I could have created the trail alone, but it would be nice to follow 
someone else's blaze.

2. Given how dangerous this one could be (to a psyche) if researched deeply 
(years of therapy…)

 =( )=Goatse  scalar / list context
 
I'd suggest another name -- Saturn.  Yes, snicker if you will.  Saturn *is* the 
son of the Greek deity Uranus, but that's only a 2nd order, inside joke.  The 
operator looks like Saturn, even when spaces are inserted (as will be likely 
with syntax formatting editors or perltidy(1))!

=( )=Saturn   scalar / list context
= ( ) =  Saturn   scalar / list context

Keep the old name if you wish, but add one that's more psychologically healthy, 
too!!!  (P.S.  Thanks for the warning.  That's just plain *responsible* 
behavior to the community!!!  One image could ruin someone's whole view of 
Perl.)

Michael

-- 
Michael R. Wolf
All mammals learn by playing!
michaelrw...@att.net





Re: Secret operators: the documentation

2012-04-03 Thread Andrew Savige


I wonder if --$| and $|--, very popular in golf, and described
by japhy as the magical flip flop variable at:

 http://www.nntp.perl.org/group/perl.fwp/2002/01/msg1367.html

qualifies as a secret operator?

/-\


Re: Secret operators: the documentation

2012-04-03 Thread Philippe Bruhat (BooK)
On Mon, Apr 02, 2012 at 06:28:56PM +0200, Alexis Sukrieh wrote:
 Le 16 mars 2012 12:44, Philippe Bruhat (BooK)
 philippe.bru...@free.fr a écrit :
  So,
 
  A few years back, I started to write a manual page about Perl secret 
  operators,
  with the goal of getting it into the official Perl documentation at some 
  point.
 [...]
  Patches welcome.
 
  When it's stabilized enough, I'll send a patch to p5p.
 
 Nice work :)
 
 I have a question though;
 
 Did you change your mind about the A word of warning section? It
 sounds that it won't fit well in the official Perl documentation ;)
 

I've pushed a branch on the Perl source tree, and Abigail already
patched the module a bit.
http://perl5.git.perl.org/perl.git/shortlog/refs/heads/book/perlsecret

The word of warning still holds. The page is specifically not listed
in the main perl.pod manual page. The idea is to hide it a little, so that
people who know about it can easily point inquiring minds to it, while not
making these official.

I also wrote a test script (t/japh/secret.t) and it helped a lot in refining
exactly how and when each of those worked.

-- 
 Philippe Bruhat (BooK)

 Did I err?  (Groo, in too many issues to count - ...and *YES* he did!)


Re: Secret operators: the documentation

2012-04-03 Thread Philippe Bruhat (BooK)
On Tue, Apr 03, 2012 at 03:43:54AM -0700, Andrew Savige wrote:
 
 
 I wonder if --$| and $|--, very popular in golf, and described
 by japhy as the magical flip flop variable at:
 
  http://www.nntp.perl.org/group/perl.fwp/2002/01/msg1367.html
 
 qualifies as a secret operator?
 

I have had several requests for adding more obscure constructs (see
https://github.com/book/perlsecret/issues). My rule has been to keep
only the well-known operators, or the ones that had a nickname that
corresponded to their looks, not their function.

Under that rulle, the magical flip-flop wouldn't have fit.

Anyway, I guess others can decide what gets in when the branch merged
into blead.

-- 
 Philippe Bruhat (BooK)

 Out of the worst can often come the best.
(Moral from Groo The Wanderer #57 (Epic))


Re: Secret operators: the documentation

2012-04-03 Thread John Douglas Porter

Philippe Bruhat (BooK) philippe.bru...@free.fr wrote:
 Andrew Savige wrote:
  
  I wonder if --$| and $|--, ... described
  by japhy as the magical flip flop variable
  qualifies as a secret operator?
 
 My rule has been to keep
 only the well-known operators, or the ones that had a
 nickname that
 corresponded to their looks, not their function.
 
 Under that rulle, the magical flip-flop wouldn't have fit.

Not to mention the fact that it's not an operator. :-)

-- 
john many jars porter



Re: Secret operators: the documentation

2012-04-02 Thread Alexis Sukrieh
Le 16 mars 2012 12:44, Philippe Bruhat (BooK)
philippe.bru...@free.fr a écrit :
 So,

 A few years back, I started to write a manual page about Perl secret 
 operators,
 with the goal of getting it into the official Perl documentation at some 
 point.
[...]
 Patches welcome.

 When it's stabilized enough, I'll send a patch to p5p.

Nice work :)

I have a question though;

Did you change your mind about the A word of warning section? It
sounds that it won't fit well in the official Perl documentation ;)

My two cents!


Re: Secret operators: the documentation

2012-04-02 Thread Pau Amma
On Mon, April 2, 2012 4:28 pm, Alexis Sukrieh wrote:
 Le 16 mars 2012 12:44, Philippe Bruhat (BooK)
 philippe.bru...@free.fr a écrit :
 So,

 A few years back, I started to write a manual page about Perl secret
 operators,
 [...]
 I have a question though;

 Did you change your mind about the A word of warning section? It
 sounds that it won't fit well in the official Perl documentation ;)

Version I saw last week-end includes:

===
You're welcome to try these at home, but they might not be safe for work!
===

Is that what you were thinking of?



Re: Secret operators: the documentation

2012-03-16 Thread Daniel Bruder
Also don't forget it is expandable, and as it is, still (erotic?) perl :-)

perl -e 'print ~~ =  = ~~ = ~~+0'


On 16 March 2012 12:44, Philippe Bruhat (BooK) philippe.bru...@free.frwrote:

 So,

 A few years back, I started to write a manual page about Perl secret
 operators,
 with the goal of getting it into the official Perl documentation at some
 point.

 Somehow I got interested in that again, and started to really work on it.
 The current work in progress is availabled at:
 https://github.com/book/perlsecret

 I've already included most of the feedback from the discussions on ~~.

 Patches welcome.

 When it's stabilized enough, I'll send a patch to p5p.

 --
  Philippe Bruhat (BooK)

  Too many believe only in the belief.
(Moral from Groo The Wanderer #58
 (Epic))



RE: Secret operators

2005-02-04 Thread McGlinchy, Alistair


Yitzchak Scott-Thoennes [mailto:[EMAIL PROTECTED] wrote:
 On Tue, Feb 01, 2005 at 09:02:56PM -, McGlinchy, Alistair wrote:
  Unfortunately -+- is bugged [*], but I'll leave these as 
 gotcha's for 
  your production code. :-)
  
  [*] You might want to consider: print-+- '-2B'  x 5;  # Bug?
 
 No.  perlop say: if the string starts with a plus or minus, a 
 string starting with the opposite sign is returned.

Hmmm. Looks like I didn't put enough smilies there.  Perhaps the much
more bugged^?^?^?^?^?^? robust reciprocal operator /// will put your
mind at rest. :-)

print ///4; # prints 0.25  :-)

Cheers,  :-)

Alistair




**
Registered Office:
Marks and Spencer plc
Waterside House
35 North Wharf Road
London
W2 1NW

Registered No. 214436 in England and Wales.

Telephone (020) 7935 4422
Facsimile (020) 7487 2670

www.marksandspencer.com

Please note that electronic mail may be monitored.

This e-mail is confidential. If you received it by mistake, please let us know 
and then delete it from your system; you should not copy, disclose, or 
distribute its contents to anyone nor act in reliance on this e-mail, as this 
is prohibited and may be unlawful.




Re: Secret operators

2005-02-04 Thread Rafael Garcia-Suarez
José Castro wrote in perl.fwp :

 Apart from the secret eskimo greeting and the goatse operator, can
 anyone tell me about other secret operators?

I think nobody mentioned the toothpick operator yet.

/\/\//

Exists also in extra-large version.

-- 
Tsk tsk, that's not an O'Reilly title. You must be thinking of Fucking
Everything Up With XML, XML Nightmares: The Definitive Guide, or
Hell  XML.
-- Nathan Torkington, http://use.perl.org/comments.pl?cid=7404sid=4864


Re: Secret operators

2005-02-04 Thread Yanick Champoux
Andrew Savige wrote:
   @{[]}   join $, ...
   

   My better half proposes to call this one the papoose operator.
Joy,
`/anick


Re: Secret operators

2005-02-04 Thread Philippe 'BooK' Bruhat
Le vendredi 04 février 2005 à 09:42, Yanick Champoux écrivait:
 Andrew Savige wrote:
 
@{[]}   join $, ...

 
My better half proposes to call this one the papoose operator.

Or the trolley operator (as in supermarkets), where you stuff everything
you want to take out.

-- 
 Philippe BooK Bruhat

 Ignorance weaves a web from which none can escape.
(Moral from Groo The Wanderer #52 (Epic))


Re: Secret operators

2005-02-03 Thread Philippe 'BooK' Bruhat
Le mercredi 02 février 2005 à 21:36, Sébastien Aperghis-Tramoni écrivait:
 Philippe 'BooK' Bruhat wrote:
 
 So we have :
 
 symbolnicknameRole
 --
 =   spaceship   documented operator
 
 0+venus   numification
 }{eskimo greeting END{} in one-liners
 =()=  goatse
 ~-inchworm on a stick high-precedence numification
 ~~inchwormscalar
 @{[]}   join $, ...
 -+-   spacestationhigh-precedence numification
 
 Not bad for a start.
 
 Hey Philippe, why don't you give the name we found for @{[]} ?
 

Because *you* found it, and want to have *my* name associated with it.

-- 
 Philippe BooK Bruhat

 All life affects us... even that which is far from our gaze.
(Moral from Groo The Wanderer #59 (Epic))


Re: Secret operators

2005-02-03 Thread Randal L. Schwartz
 Eugene == Eugene van der Pijll [EMAIL PROTECTED] writes:

 @{[]}  aka ???The Schwartz   early 1990s

Eugene The Larry, May 1 1994
Eugene  http://groups-beta.google.com/group/comp.lang.perl/msg/1d82c7c3f3e94266

The array version was actually discussed in private email between me
and Larry, if I recall correctly, shortly before that public post,
because I had come up with it for some courseware of mine.

But, this *is* 10 years ago, and I could be mismembering.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
merlyn@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


Re: Secret operators

2005-02-03 Thread Yitzchak Scott-Thoennes
On Wed, Feb 02, 2005 at 04:20:05PM +0200, Vladi Belperchinov-Shabanski wrote:
 On Wed, 2 Feb 2005 12:33:35 +1100 (EST)
 Andrew Savige [EMAIL PROTECTED] wrote:
 
  Jos_ Castro wrote:
   Apart from the secret eskimo greeting and the goatse operator,
   can anyone tell me about other secret operators?
  
  Let's not forget the Ton Hospel high-precedence decrement
  operator ~- invented during a golf tournament (anyone remember
  which one?).
  
  IIRC, Ton's ~- invention allows you to eliminate the parens in:
  
  $y = ($x-1)*4;
  
  by using instead:
  
  $y = ~-$x*4;
  
  saving a whopping two strokes. This trick should work on any
  twos complement machine -- and I'm not aware of any perl running
  on any non twos complement machine.
 
 will not work if $x  0

Except under use integer.  A little known fact is that perl's bitops
cast operands to unsigned integers without use integer and to signed
integers with use integer.


Re: Secret operators

2005-02-02 Thread Eric Krohn

Andrew Savige wrote:
 twos complement machine -- and I'm not aware of any perl running
 on any non twos complement machine.

I ported Perl 1.0 (and probably 2.0) to UNIX 1100 (UNIX as guest OS on
Univac 1100).  The machine was 36-bit, ones complement, word addressable. 
Porting software to this beast was often a challenge.  Fortunately, I
haven't had to use that hardware in a long, long time (~1989)!

--
Eric Krohn


Re: Secret operators

2005-02-02 Thread José Castro
* McGlinchy, Alistair ([EMAIL PROTECTED]) wrote:
 Hi All,
 
 High in fun, but low in usefulness is -+- , a high precedence string
 numerifier. It sort of looks like an A C Clarke style spacestation so
 that's what I've been calling it. Although I'm not too sure that Larry's
 spaceship =3D would be able to dock to easily.

Of course it would!

  =
   |
   +
   |

Larry's probably been there a couple of times...

 Examples:
   print -+-'23a'# prints 23
   print -+-'3.00'   # prints 3=09
   print -+-'1.2e3'  # prints 1200
 =09
 I know 0+ does the trick too, but binary + has a relatively low
 precedence. Perl will automatically numerify the arguments of the *
 operator but won't do so for x, !~ or =3D~. Hence this operator is =
 useful
 for removing unsightly parenthesises from some expressions.
 
   print 0+'20GBP'   x 3;  # Wrong. Prints 20   =3D=3D
 0+20GBP20GBP20GBP
   print (0+'20GBP') x 3;  # Wrong. x 3 is applied to the return of
 print
   print((0+'20GBP') x 3); # Right, but too Lispy=20
   print -+-'20GBP'  x 3;  # Right. Spacestation to the rescue!
 
 Unfortunately -+- is bugged [*], but I'll leave these as gotcha's for
 your production code. :-)
 
 
 
 Cheers,
 
 Alistair
 
 [*] You might want to consider: print-+- '-2B'  x 5;  # Bug?
 
 
 ---
 
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D
 Registered Office:
 Marks and Spencer plc
 Waterside House
 35 North Wharf Road
 London
 W2 1NW
 
 Registered No. 214436 in England and Wales.
 
 Telephone (020) 7935 4422
 =46acsimile (020) 7487 2670
 
 www.marksandspencer.com
 
 Please note that electronic mail may be monitored.
 
 This e-mail is confidential. If you received it by mistake, please =
 let us know and then delete it from your system; you should not =
 copy, disclose, or distribute its contents to anyone nor act in =
 reliance on this e-mail, as this is prohibited and may be unlawful.
--
Jose Alves de Castro [EMAIL PROTECTED]
  http://jose-castro.org/


Re: Secret operators

2005-02-02 Thread Vladi Belperchinov-Shabanski
On Wed, 2 Feb 2005 12:33:35 +1100 (EST)
Andrew Savige [EMAIL PROTECTED] wrote:

 Jos_ Castro wrote:
  Apart from the secret eskimo greeting and the goatse operator,
  can anyone tell me about other secret operators?
 
 Let's not forget the Ton Hospel high-precedence decrement
 operator ~- invented during a golf tournament (anyone remember
 which one?).
 
 IIRC, Ton's ~- invention allows you to eliminate the parens in:
 
 $y = ($x-1)*4;
 
 by using instead:
 
 $y = ~-$x*4;
 
 saving a whopping two strokes. This trick should work on any
 twos complement machine -- and I'm not aware of any perl running
 on any non twos complement machine.

will not work if $x  0

 
 /-\
 
 
 Find local movie times and trailers on Yahoo! Movies.
 http://au.movies.yahoo.com
 


-- 
Vladi Belperchinov-Shabanski [EMAIL PROTECTED] [EMAIL PROTECTED]
Personal home page at http://cade.datamax.bg/
DataMax SA   http://www.datamax.bg
there is still one truth on which we can depend
we've started something we can never end


pgpXeOAMawvJG.pgp
Description: PGP signature


Re: Secret operators

2005-02-02 Thread Sébastien Aperghis-Tramoni
Philippe 'BooK' Bruhat wrote:
So we have :
symbolnicknameRole
--
=   spaceship   documented operator
0+venus   numification
}{eskimo greeting END{} in one-liners
=()=  goatse
~-inchworm on a stick high-precedence numification
~~inchwormscalar
@{[]}   join $, ...
-+-   spacestationhigh-precedence numification
Not bad for a start.
Hey Philippe, why don't you give the name we found for @{[]} ?
Sébastien Aperghis-Tramoni
 -- - --- -- - -- - --- -- - --- -- - --[ http://maddingue.org ]
Close the world, txEn eht nepO


Re: Secret operators

2005-02-02 Thread Quantum Mechanic

--- Philippe 'BooK' Bruhat [EMAIL PROTECTED]
wrote:
 
 symbolnicknameRole
 --
 =   spaceship   documented
 operator
 
 0+venus   numification
 }{eskimo greeting END{} in
 one-liners
 =()=  goatse
 ~-inchworm on a stick
 high-precedence numification
 ~~inchwormscalar
 @{[]}   join $, ...
 -+-   spacestation   
 high-precedence numification
 

Other naming suggestions:

 ~- inchworm
or cotton candy (on a stick)
 ~~ caterpillar
 @{[]}cyclops (one eye with eyebrows,
mustache, and square mouth)
 -+-cross-hair (or half cross-hair)
or vanishing point (horizon line)
or reticule
 ]-[   Frowning Sam (resembles the Muppet
named Sam the Eagle)
Beaker (the nerdish Muppet with the
perpetual surprised look)


=
~~
Quantum Mechanics: The dreams stuff is made of



__ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 



Re: Secret operators

2005-02-02 Thread Eugene van der Pijll
Andrew Savige schreef:
 The table below is based on wild guesswork. If there are any oldbies
 listening, please chime in with corrections.

Not an oldbie, but...

 @{[]}  aka ???The Schwartz   early 1990s

The Larry, May 1 1994
 http://groups-beta.google.com/group/comp.lang.perl/msg/1d82c7c3f3e94266

 y///c aka Abigail's Length Horror The Abigaillate 1990s

Although I agree about the name, the inventor seems to have been The
Hall, Jun 22 1996
 http://groups-beta.google.com/group/comp.lang.perl.misc/msg/7680c5d579b5fc23

 stuff value into $\ for printing  The van der Pijll  2001

I'm almost sure that I've seen a very early post by Larry, Randal, or
Tom Christiansen (most probably Larry), where this trick is used. I did
come up with it independently, though.

gr,Eu


Re: Secret operators

2005-02-02 Thread Chris Dolan
On Feb 2, 2005, at 2:36 PM, Sébastien Aperghis-Tramoni wrote:
Hey Philippe, why don't you give the name we found for @{[]} ?
It looks like a guy lying on his side in a straightjacket to me.
Chris
--
Chris Dolan, Software Developer, www.chrisdolan.net
Public key: http://www.chrisdolan.net/public.key


PGP.sig
Description: This is a digitally signed message part


Re: Secret operators

2005-02-02 Thread Bart Lateur
On Tue, 1 Feb 2005 11:49:57 +, José Castro wrote:can

anyone tell me about other secret operators?

I just produced this in my own code, I think it would qualify. Take this
expression in list context:

cond ? foo : ()

I'm talking about the 3 characters at the end: : (). I'd call it a
frogs face.

-- 
Bart.


Re: Secret operators

2005-02-01 Thread Philippe 'BooK' Bruhat
Le mardi 01 février 2005 à 11:49, José Castro écrivait:
 Hi, guys.
 
 Apart from the secret eskimo greeting and the goatse operator, can
 anyone tell me about other secret operators?
 
 Examples:
 
 eskimo:   }{
 goatse:   =()=
 
 eskimo usage:   perl -ne '}{print $.'
 goatse usage:   perl -e '$_=zbrughau;$b=()=/u/g;print $b'

There's also @{[]} but I don't know f it has a name.

Usage: print splatt @{[ ... ]} pow
where ... is any valid expression, and the result list is join()ed with $
(space).

-- 
 Philippe BooK Bruhat

 There are two sides to every cause. Do not join one until you know the other.
   (Moral from Groo The Wanderer #105 (Epic))


Re: Secret operators

2005-02-01 Thread Vladi Belperchinov-Shabanski
On Tue, 1 Feb 2005 11:49:57 +
Jos_ Castro [EMAIL PROTECTED] wrote:

 Hi, guys.
 
 Apart from the secret eskimo greeting and the goatse operator, can
 anyone tell me about other secret operators?
 
 Examples:
 
 eskimo:   }{
 goatse:   =()=
 
 eskimo usage:   perl -ne '}{print $.'

   perl -MO=Deparse -ne 'print $.'

has this actual code:

   LINE: while (defined($_ = ARGV)) {
   print $.;
   }

on the other hand your example:


   perl -MO=Deparse -ne '}{print $.' 

actually is:


   LINE: while (defined($_ = ARGV)) {
   ();
   }
   {
   print $.;
   }

the trick is that you can have loop and finish code:

   perl ' loop-code-here }{ finish-code-here'

 goatse usage:   perl -e '$_=zbrughau;$b=()=/u/g;print $b'

   $b = () = /u/g;

is the same as:

   @a = /u/g;
   $b = @a;

i.e. () forces array context (actually it is array), then returns element count 
in $b

no big secrets here, though I never thought of such () use. thanks for the hint 
:))

-- 
Vladi Belperchinov-Shabanski [EMAIL PROTECTED] [EMAIL PROTECTED]
Personal home page at http://cade.datamax.bg/
DataMax SA   http://www.datamax.bg
there is still one truth on which we can depend
we've started something we can never end


Re: Secret operators

2005-02-01 Thread Philippe 'BooK' Bruhat
Le mardi 01 février 2005 à 18:57, Vladi Belperchinov-Shabanski écrivait:
 On Tue, 1 Feb 2005 15:57:33 +0100
 [EMAIL PROTECTED] (Philippe 'BooK' Bruhat) wrote:
 
  
  There's also @{[]} but I don't know f it has a name.
  
  Usage: print splatt @{[ ... ]} pow
  where ... is any valid expression, and the result list is join()ed with $
  (space).
 
 [] construct reference to anonymous array, @{} dereferences the array ref. 
 finally the array is interpolated inside string.
 
 it is equal to:
 
   @a = ( 1, 2, 3 );
   print splatt @a pow;
 
 the only use is to force array context inside string:
 
   %a = ( 1, 2, 3 );
   print splatt @{[%a]} pow;
   
 but don't think it is usefull (except obfuscation bonus:))

I won't defend its usefulness (we're here for fun), but sometimes you
don't want to type

use Acme::MetaSyntactic 'batman';
print splatt  . join(  , metaname(3) ) .  pow;

when

use Acme::MetaSyntactic 'batman';
print splatt @{[metaname 3]} pow;

will do.

-- 
 Philippe BooK Bruhat

 A reputation is only as good as the truth beneath it, if any.
(Moral from Groo The Wanderer #91 (Epic))


Re: Secret operators

2005-02-01 Thread Andy_Bach
Can I get that just a little slower?

 $b = () = /u/g;

is the same as:

   @a = /u/g;
   $b = @a;

I understand what happens, but it appears to be assigning to an empty list 
- is that filling up the list, so to speak?  Or is it just that it makes 
the 'result' of /u/g assign in array/list context and then that, assigned 
in scalar context to $b gives the list/array count. 

I tried to explain this once and I had to resort to 'and then mumble 
mumble and in scalar context, we get the count of the elements in $b!'

a

Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED] 
VOICE: (608) 261-5738  FAX 264-5932

Bugs happen. A bug is a test case you haven't written yet.
Mark Pilgrim


Re: Secret operators

2005-02-01 Thread Georg Moritz
From the keyboard of [EMAIL PROTECTED] [01.02.05,11:15]:

 Can I get that just a little slower?

  $b = () = /u/g;

 is the same as:

@a = /u/g;
$b = @a;

it's not the same.

perl -le '$_=foo; print $b =()= /o/g'
2
perl -le '$_=foo; print @b =()= /o/g'

perl -le '$_=foo; print /o/g'
oo

The brackets in =()= means something like 'here would have been n elements,
were you interested'. There's no list, only list context.

-gg-

 I understand what happens, but it appears to be assigning to an empty list
 - is that filling up the list, so to speak?  Or is it just that it makes
 the 'result' of /u/g assign in array/list context and then that, assigned
 in scalar context to $b gives the list/array count.

 I tried to explain this once and I had to resort to 'and then mumble
 mumble and in scalar context, we get the count of the elements in $b!'

 a

 Andy Bach, Sys. Mangler
 Internet: [EMAIL PROTECTED]
 VOICE: (608) 261-5738  FAX 264-5932

 Bugs happen. A bug is a test case you haven't written yet.
 Mark Pilgrim


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



Re: Secret operators

2005-02-01 Thread José Castro
* Ronald J Kimball ([EMAIL PROTECTED]) wrote:
 You can assign two elements to a one-element list:
 
 ($foo) = (1, 2);
 
 You can even assign two elements to an empty list:
 
 () = (1, 2);
 
 
 In each case, any extra elements are simply discarded, but the result of
 the assignment in scalar context is always the number of elements on the
 right-hand side, even if some aren't actually assigned to variables.

Which is why this:

perl -e '$_ = ($foo) = (1, 2) ; print'

prints out 2.

--
Jose Alves de Castro [EMAIL PROTECTED]
  http://jose-castro.org/


Re: Secret operators

2005-02-01 Thread Jeff Yoak
On Tue, 2005-02-01 at 03:49, Jos Castro wrote:
 Hi, guys.
 
 Apart from the secret eskimo greeting and the goatse operator, can
 anyone tell me about other secret operators?
 
 Examples:
 
 eskimo:   }{
 goatse:   =()=
 
 eskimo usage:   perl -ne '}{print $.'

This is wonderfully deranged.  I haven't seen it before, but it was
immediately clear what it does.

 goatse usage:   perl -e '$_=zbrughau;$b=()=/u/g;print $b'

This is probably even more wonderfully deranged as it *isn't* clear what
it does, even after running it.  Can you explain this one?  And also,
what does the name goatse mean?

Cheers,
Jeff




Re: Secret operators

2005-02-01 Thread José Castro
* Jeff Yoak ([EMAIL PROTECTED]) wrote:
  eskimo usage:   perl -ne '}{print $.'
 
 This is wonderfully deranged.  I haven't seen it before, but it was
 immediately clear what it does.
 
  goatse usage:   perl -e '$_=zbrughau;$b=()=/u/g;print $b'
 
 This is probably even more wonderfully deranged as it *isn't* clear what
 it does, even after running it.  Can you explain this one?  And also,
 what does the name goatse mean?

You had to ask about the name, didn't you? :-)

See the explanation here: http://perlmonks.org/?node_id=426037

You can follow this link safely (it's a perlmonks node), but a word of
caution: in that thread, a guy explains the origin of the name, and
provides another link... for the love of god, *do not* follow that
link!!! :-)

Regards,

jac

--
Jose Alves de Castro [EMAIL PROTECTED]
  http://jose-castro.org/


Re: Secret operators

2005-02-01 Thread Quantum Mechanic

--- José Castro [EMAIL PROTECTED] wrote:

 * Quantum Mechanic ([EMAIL PROTECTED])
 wrote:
  $foo = ($bar) = (9,8,7);
  
  RHS list
  ($bar) array
  $bar - 7 (rest discarded)
 
 No, no, no.
 
   $bar - 9
 

Yes, that was a typo -- thanks.

 It's the same as
 
   $foo = ($bar, undef, undef) = (9, 8, 7);
 
 Now the funny thing is that the result from
 
   $foo = ($bar, undef, undef, undef) = (9, 8, 7);
 
 is still the same :-)

Ah, but that supports my theory. It's not the LHS of
the ($bar,...)= assignment that generates the data for
$foo -- it's the RHS. The LHS of the ($bar,...)=
assignment determines the *context* of the $foo=
assignment.

Q.E.D. The quantity of elements on the LHS don't
matter, but the quality of the LHS does.

-QM

=
~~
Quantum Mechanics: The dreams stuff is made of



__ 
Do you Yahoo!? 
Yahoo! Mail - now with 250MB free storage. Learn more.
http://info.mail.yahoo.com/mail_250


Re: Secret operators

2005-02-01 Thread Andrew Savige
José Castro wrote:
 Apart from the secret eskimo greeting and the goatse operator,
 can anyone tell me about other secret operators?

Let's not forget the Ton Hospel high-precedence decrement
operator ~- invented during a golf tournament (anyone remember
which one?).

IIRC, Ton's ~- invention allows you to eliminate the parens in:

$y = ($x-1)*4;

by using instead:

$y = ~-$x*4;

saving a whopping two strokes. This trick should work on any
twos complement machine -- and I'm not aware of any perl running
on any non twos complement machine.

/-\


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com


Re: Secret operators

2005-02-01 Thread Andrew Savige
Philippe 'BooK' Bruhat wrote: 
 So we have :
 
 symbolnicknameRole
 --
 =   spaceship   documented operator
 
 0+venus   numification
 }{eskimo greeting END{} in one-liners
 =()=  goatse
 ~-inchworm on a stick high-precedence numification
 ~~inchwormscalar
 @{[]}   join $, ...
 -+-   spacestationhigh-precedence numification

For the sake of the Perl historians, it would be nice to properly
attribute these inventions.

The table below is based on wild guesswork. If there are any oldbies
listening, please chime in with corrections.

Secret Operator   Inventor   Year
---      

@{[]}  aka ???The Schwartz   early 1990s
}{ aka eskimo greetingThe Abigaillate 1990s
=()=   aka goatse ???
-+-aka spacestation   The McGlinchy  ???
~~ aka inchworm   ???
~- aka inchworm-on-a-stickThe Hospel 2002

We could also classify golfing techniques:

Golfing Technique Inventor   Year
-    

$_ x= boolean expression  The Larry  early 1990s
y///c aka Abigail's Length Horror The Abigaillate 1990s
stuff value into $\ for printing  The van der Pijll  2001
}for(...){ variation of eskimoThe Hospel 2001
--$| magical flip-flopThe Hospel 2002
\$h{X} is one less than ++$h{X}
   aka Thelen's DeviceThe Thelen 2002
-i and $^I for data value The Sperling   2002

Notice that some of the secret operators above also double as
golfing techniques. I'm sure there are plenty of other golfing
techniques I've forgotten because I am so rusty.

/-\


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com