Commas

osfameron on 2005-01-22T09:22:43

Being able to put commas at the end of hash declarations is a small but handy productivity enhancement. If you have declared

my %hash = (
  a => 1,
  b => 2,
  c => 3,
);


then you can reorder, for example, the b and c entries without having to add a comma after c and remove it after b. On an Oracle course, I learnt an SQL idiom of putting commas before the line:
select
   name
  ,age
  ,hair
from ...
giving similar benefits (not for the first line of course). Out of longstanding Perl habit, I did the same in Javascript

var obj = {
  a: 1,
  b: 2,
  c: 3,
};


which works in the Spidermonkey javascript as implemented in Firefox etc., but not in MSIE, where it gives an "Object expected" error. (Actually it gave the error on the wrong line due to not processing script includes properly, but that's another story).