Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What does the => mean in Perl?

my $CreateArray = [
objectClass => [ "top", "person", "organizationalPerson", "inetOrgPerson" ],
cn => "Jane User",
uid => "0000001",
sn => "User",
mail => ""


0  'objectClass'
1  ARRAY(0x104ef40)
  0  'top'
  1  'person'
  2  'organizationalPerson'
  3  'inetOrgPerson'
2  'cn'
3  'Jane User'
4  'uid'
5  0000001
6  'sn'
7  'User'
8  'mail'
9  ''

It seems that even numbers are keys and odd numbers are values. Why don't they use hashes? Because they aren't ordered? Is there a name for this strange structure?

Thank you.

share|improve this question
A name for the structure in the top code box or the bottom? Please clarify a bit so that I can improve my answer. – Dynamic Aug 12 '12 at 21:04
Thank you for your answer. Well, I meant both boxes and especially the "comma operator". I didn't know this term and thought it's a hash. I didn't know that flat structures are used for pairs of keys and values. – chris Aug 12 '12 at 21:56
There's also a winking fat comma. – Chankey Pathak Nov 21 '12 at 5:12
up vote 8 down vote accepted

Generally, the "big arrow" (=>) in Perl is basically a comma, with one difference: everything on its left is treated as if it is quoted. So this:

Foo => Bar

Is the same as:

'Foo', Bar

For more info, see perlop.

share|improve this answer
The left hand side is only quoted if it's strictly composed of Perl identifier characters. – brian d foy Nov 18 '13 at 9:31

Agreed, see perlop (perldoc perlop) for details.

For more discussion, here's a decent thread. Don't confuse the key=>value notation as being significant to a hash...

For example:

# no =>
my %hash = (
  mykey, 'blah',
  yourkey, 'blah2',
  seehere, 'blah3',
  90, 'see further -- try putting a 0 in front of my key');

foreach my $key (sort keys %hash) {
  print qq#$key: $hash{$key}\n#;


But arrows will do just as well, without quotes, avoid unquoted octals.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.