Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

osfameron (3135)

osfameron
  (email not shown publicly)
http://greenokapi.net/blog/

Technorati Profile [technorati.com]

Journal of osfameron (3135)

Saturday January 22, 2005
04:22 AM

Commas

[ #22833 ]
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).

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.