I stumbled upon this list of "hidden features of perl" and thought it'd a good idea if I got some of your replies as well!
http://stackoverflow.com/questions/161872/hidden-features-of-perl
Just as on the site, here a few "requirements":
Try to limit answers the Perl core and not CPAN
Please give an example and a short description
|
---|
Replies are listed 'Best First'. | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Re: Hidden features of Perl (More Secret Operator References)
by eyepopslikeamosquito (Archbishop) on Jun 22, 2009 at 23:44 UTC | ||||||||||||||||
Some old PM nodes I remember that seem relevant: From The Lighter Side of Perl Culture (Part IV): Golf, some "hidden golfing features":
Update: BooK has recently popularized a new set of secret operators, the screwdriver operators: These screwdriver operators follow on from earlier secret operator work, such as Dmitry Karasik's original set of "!"-based secret operators and BooK's flaming X-wing operator (@data{@fields} =<>=~ $re). Jan 2010 Update: LanX created a "poll" (really a meditation) at Poll: How should the =( )= be called??? in an attempt to solve the well-known naming issues of this idiom: =( )=. Though Rolex narrowly defeated Saturn back then, nowadays LanX prefers wristwatch. March 2012 Update: BooK at it again, this time proposing a new sperm secret operator. An alternative name is the "kite" secret operator. From perlsecret: Perl secret operators: Update: for the inchwormy operators above, see also the "Inchworm" and "Inchworm on a stick" sections at perlsecret and The Lighter Side of Perl Culture (Part IV): Golf (search for inchworm). Perl secret constants:
October 2014 Update: Re: Perl Idioms Explained - ${\$obj->method} and @{[sort @list]} by ambrus proposes a new "twin baby cart" operator, as used by tybalt89 and tails in winning golf entry at shinh's golf site:
See also: BooK proposes a new Perl secret operator (Secret Operator References) and Perl Secret Operator Emojis (2023) | [reply] [d/l] [select] | |||||||||||||||
by ambrus (Abbot) on Jun 23, 2009 at 17:06 UTC | ||||||||||||||||
I think this series is related as well: | [reply] | |||||||||||||||
by cdarke (Prior) on Jun 29, 2009 at 11:06 UTC | ||||||||||||||||
| [reply] [d/l] | |||||||||||||||
by eyepopslikeamosquito (Archbishop) on Jun 29, 2009 at 11:43 UTC | ||||||||||||||||
Originally, a crude name was proposed for this operator, as indicated by this response from BooK to Sebastien Aperghis-Tramoni:
> Hey Philippe, why don't you give the name we found for @{[]} ? To deflect attention from the taboo name, BooK started another fwp thread, suggesting "Baby Cart" ... which was objected to by native English speakers on the grounds they'd never heard it used in everyday speech. Suggested alternatives included "Baby Carriage" and "Pram". Though many other names have been proposed, including: it seems that BooK's quirky Baby Cart has won this fascinating naming war. BooK References
Quoting BooK from Interview with Philippe Bruhat (August 2015): I've been hanging around on the Fun with Perl mailing for a long time, and this is where José Castro started to ask for the names of the most famous secret operators for his OGSOP (Obfuscation, Golfing and Secret Operators in Perl) book project. I came up with the name "baby cart" for @{[]}, and I loved that name so much that I wanted to make sure it would be the one that everyone would use. The only way to do that was to write the reference manual myself... Early Historical References
References Added Later
Comparing Baby Cart with String Interpolation in Other Languages (Golf) Though usually too long for golf, Baby Cart occasionally features in competitive golf solutions, as you will discover by searching for Baby Cart in the following nodes: Based on these nodes, consider how to create a "Dear John" string in each of the four languages:
My 102 stroke Perl solution to the Saving Time challenge used Baby Cart to create a printf format string on the fly:
What's the shortest way to create this peculiar printf format string from an expression (expr) in each of the four languages?
where X above is the character with ord value 218. Poor old Baby Cart baby-stepped to the finish line in last place in this oddball race. This is hardly surprising given Baby Cart was not really designed; it was independently "invented" shortly after Perl 5 was released in 1994 by both L.Wall and R.Schwartz ... and later celebrated as one of Perl's secret operators. Updated: Many changes were made and extra references added long after the original response was made. | [reply] [d/l] [select] | |||||||||||||||
by ccn (Vicar) on Aug 10, 2009 at 19:14 UTC | ||||||||||||||||
| [reply] [d/l] [select] | |||||||||||||||
Re: Hidden features of Perl
by Arunbear (Prior) on Jun 22, 2009 at 10:12 UTC | ||||||||||||||||
[reply] | ||||||||||||||||
Re: Hidden features of Perl
by Jenda (Abbot) on Jun 22, 2009 at 13:24 UTC | ||||||||||||||||
Esoteric? What the heck is esoteric about them? Agrrr. Anything that's not apparent to someone with strictly imperative background with no computer science knowledge whatsoever is deemed "esoteric". Nonsense. Jenda | [reply] | |||||||||||||||
by educated_foo (Vicar) on Jun 22, 2009 at 14:36 UTC | ||||||||||||||||
| [reply] | |||||||||||||||
by vxp (Pilgrim) on Jun 22, 2009 at 20:24 UTC | ||||||||||||||||
It seems that you are arguing semantics, which isn't the point of this post.. post whatever _you_, personally, consider a "hidden feature". Don't worry about what others consider esoteric. :) | [reply] | |||||||||||||||
by Jenda (Abbot) on Jun 22, 2009 at 19:23 UTC | ||||||||||||||||
Most of the stuff is something that looks esoteric to someone who was taught C or Fortran or who taught him/her-self VB and is so used to imperative programming, that he/she cannot think outside that old tiny box. The people that find references hard and higher order functions rocket science. And the DATA filehandle is no more esoteric than a print statement. A bit unusual maybe, non-obvious probably, but esoteric? That's a very big stretch of the meaning of the word. Jenda | [reply] | |||||||||||||||
by educated_foo (Vicar) on Jun 23, 2009 at 02:58 UTC | ||||||||||||||||
by Porculus (Hermit) on Jun 23, 2009 at 14:00 UTC | ||||||||||||||||
Re: Hidden features of Perl
by Anonymous Monk on Jun 22, 2009 at 02:28 UTC | ||||||||||||||||
| [reply] | |||||||||||||||
by vxp (Pilgrim) on Jun 22, 2009 at 04:06 UTC | ||||||||||||||||
| [reply] [d/l] | |||||||||||||||
Re: Hidden features of Perl
by whakka (Hermit) on Jun 22, 2009 at 23:23 UTC | ||||||||||||||||
[reply] |