[sf-perl] Unusual Perl "feature"
kvale at phy.ucsf.edu
Tue Feb 19 08:51:19 PST 2013
On 02/17/2013 06:40 PM, Quinn Weaver wrote:
> On Feb 15, 2013, at 4:14 PM, Mark Kvale wrote:
>> This is documented behavior; see
>> 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.
> Perl is like hobbits, to paraphrase Gabdalf: you can know it for
> years, and yet still it can surprise you. :)
> -- Quinn Weaver PostgreSQL Experts, Inc. http://pgexperts.com/
> 1-888-743-9778 (my extension: 510)
Sorry for not being clear. You do need the quotes if you want a leading
'-', unless there is a special rule. From perlop, comma
"The => operator is a synonym for the comma except that it causes a word
on its left to be interpreted as a string if it begins with a letter or
underscore and is composed only of letters, digits and underscores."
My guess is that the interpreter sees -title as '-' and 'title',
converts 'title' to a string because it starts with a letter, then
prepends '-' to the string according to the special rule.
More information about the SanFrancisco-pm