Fat comma

From Seo Wiki - Search Engine Optimization and Programming Languages

Jump to: navigation, search

Fat comma is a programming term primarily associated with the Perl and Ruby programming languages, though others doubtless also employ the token. It refers to an operator, indicated as “=>”, that can be used as a substitute for the comma operator and is an example of good idiomatic Perl when used to bind key-value pairs in a hash.[1]

# a typical, idiomatic use of the fat comma in Perl
my %newHash = ( first_name => "Tom", last_name => "Auger" );


When working under strict mode (a solid programming practice that forces the developer to adhere to the highest standards of consistency, typing and declaration available to the language's compiler), the fat comma has one advantage over its comma (“,”) analogue: it forces the word to its left to be interpreted as a string.[2]

Thus, where

use strict; # for the love of Larry, use strict!
my %badHash = ( bad_bareword, "not so cool" );

would produce a run-time error (barewords are not allowed under strict), the following use of the fat comma

use strict;
my %goodHash = ( converted_to_string => "very monkish" );

would be legal and idiomatic, because the token converted_to_string would be converted to the string literal "converted_to_string" which is a legal argument in a hash key assignment. The result is easier-to-read code, with a stronger emphasis on the name-value pairing of associative arrays.


  1. Conway, Damian. "4: Values and Expressions". in Allison Randal and Tatiana Appandi. Perl Best Practices. O'Reilly Media, Inc.. pp. 66. ISBN 0-596-00173-8. "Whenever you are creating a list of key/value or name/value pairs, use the "fat comma" (=>) to connect the keys to their corresponding values." 
  2. perldoc.perl.org – perlop – Comma Operator
Personal tools

Served in 0.145 secs.