[sf-perl] Unusual Perl "feature"

Quinn Weaver quinn at pgexperts.com
Tue Feb 19 10:09:16 PST 2013


Nice catch! That makes total sense. I wrote a Perl/Tk app once, but I'd forgotten all about the -key convention. It Just Worked, so I never really thought about it. DWIM for the win.

--
Quinn Weaver
PostgreSQL Experts, Inc.  http://pgexperts.com/
1-888-743-9778 (my extension: 510)
Sent from my phone; pardon my brevity.

On Feb 18, 2013, at 1:09 PM, Uri Guttman <uri at stemsystems.com> wrote:

> On 02/17/2013 09:40 PM, Quinn Weaver wrote:
>> On Feb 15, 2013, at 4:14 PM, Mark Kvale wrote:
>> 
>>> This is documented behavior; see
>>> 
>>> http://perldoc.perl.org/perlop.html#Symbolic-Unary-Operators
>>> 
>>> My guess on use? As the man says, '-bareword is equivalent to the string "-bareword"', allowing for fat comma keys without needing quotes, e.g.
>>> 
>>> (-bareword => 1, -title => 2)
>> 
>> But you don't need to quote keys anyway. This feature must exist for some other reason.
> 
> it was allowed because of perl/tk where all the keys (as in regular tk) are -foo style. so perl allows barewords of -foo to be autoquoted by =>.  this also allowed the - prefix to be a simple prefix - to the string op which is useful for those types of keys.
> 
> uri
> _______________________________________________
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
> http://mail.pm.org/mailman/listinfo/sanfrancisco-pm


More information about the SanFrancisco-pm mailing list